A payment link automatic switching method

Through the multi-link payment convergence technology and dynamic monitoring mechanism, the problem of a single payment channel for POS machines in the medical beauty industry is solved, automatic payment link switching is realized, and the reliability and security of the payment process is improved. It is suitable for smart POS ends.

CN111754216BActive Publication Date: 2024-11-22BEIJING KAIWEI YUNCHUANG INFORMATION TECHNOLOGY CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202010562631.8
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2020-06-19
Publication Date
2024-11-22
Estimated Expiration
2040-06-19

AI Technical Summary

Technical Problem

POS machines in the medical beauty industry usually can only use a single payment channel, and cannot achieve effective cluster deployment and dynamic monitoring of multiple payment channels, resulting in unreliable payment links.

Method used

It adopts multi-link payment convergence technology, and logs into the platform through the service gateway, monitors the status of the POS machine, dynamically monitors and selects available payment channels, realizing automatic switching of payment links, ensuring the seamlessness and security of the payment process.

Benefits of technology

It realizes seamless switching of multi-payment channels, improves the reliability and security of the payment process, reduces the risks of funds and information, simplifies the complexity of internal service calls, and supports multiple deployment scenarios.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN111754216B_ABST
    Figure CN111754216B_ABST
Patent Text Reader

Abstract

A payment link automatic switching method, S1. A user logs in to the platform through a service gateway, prepares to make a payment, and monitors the status of a POS machine; S2. Wakes up and enables a payment channel monitoring service; S3. Monitors the payment channel status; S4. Lists available payment channels and selects a default payment channel; S5. Selects a payment channel; S7. Scans the payment channel; S8. Reads the payment channel from a cache, and the payment monitoring service scans the payment channel interface at intervals. If the payment channel currently being used by the user has an exception, it checks whether there are other available payment channels. If not, it prompts the user that payment is currently unavailable. Otherwise, it automatically switches to an available payment channel, and at the same time obtains the information that the user has selected and input in the context, and seamlessly switches to the service of the reselected payment channel. The user completes payment on the new channel without the user noticing during the process; S9. The exception code is processed and a receipt is printed, and the payment process ends.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention relates to a payment method, and in particular to an automatic payment link switching method. Background Art

[0002] At present, all single POS payment channels in the medical beauty industry are single-channel payment channels, and no POS manufacturer can integrate multiple payment channels into one POS machine. However, the link payment fusion technology can seamlessly integrate multiple payment channels into one POS machine. The effectiveness of multiple payment channels allows users to complete seamless switching and effective payment without any perception.

[0003] Previous technologies were based on single-channel communication implementation, which only kept the current channel payment status normal, so it could not solve the problem of multiple payment channel cluster deployment and dynamic monitoring of payment channel survival. This technology realizes dynamic monitoring and dynamic routing of payment channels, can judge the current valid payment channel in real time, and select the most effective payment channel for POS payment. Summary of the invention

[0004] In order to overcome the shortcomings of the existing technical solutions, the present invention focuses on the medical beauty industry, applies multi-link payment fusion technology, solves the problem of using a single payment channel in the medical beauty industry, and is mainly applied to the smart POS terminal payment module. A payment link automatic switching method is provided.

[0005] In order to achieve the above object, the technical solution of the present invention is: a payment link automatic switching method,

[0006] S1. The user logs in to the platform through the service gateway, prepares to make a payment, monitors the POS machine status, and enters S2 if it is in the startup state. Otherwise, the payment channel service does not start, and the user is prompted to start the machine;

[0007] S2. Wake up and enable the payment channel monitoring service, call the interface and return the available payment channels;

[0008] S3. Monitor the payment channel status, scan the payment channel port regularly, and return the status code: the payment monitoring service scans the current payment channel interface at an interval (every 5 seconds, the interval is configurable), returns the status code of each payment channel (000 indicates that the channel is normal, and other status codes indicate that the payment channel is abnormal), and puts all status codes into the payment channel cache;

[0009] S4. List available payment channels and select the default payment channel: the system automatically selects the default normal payment channel. If all payment channels are unavailable, a warning will be displayed directly on the POS interface, indicating that payment cannot be made normally.

[0010] S5. Select the payment channel and prepare to pay. The user swipes the card, pays by QR code, and enters the verification password;

[0011] S7. Scan the payment channel and place the available information in the cache;

[0012] S8. The payment channel is read from the cache, and the payment monitoring service scans the payment channel interface at intervals. If the payment channel currently used by the user has an exception, it checks whether there are other available payment channels. If not, it prompts the user that payment is currently unavailable. Otherwise, it automatically switches to an available payment channel, and obtains the information that the user has selected and entered in the context, and seamlessly switches to the service of the newly selected payment channel. The user completes the payment on the new channel without the user being aware of it.

[0013] S9. Exception code processing and receipt printing: If UnionPay or the payment institution does not return a normal payment success code within the valid time, or returns an exception code, and the system scans that the current POS machine has an exception payment code or does not return after a timeout, the user will be informed that the payment was not successful. UnionPay or the payment institution will complete the fund reconciliation and refund operations within an appropriate period of time, and change the current payment order status to payment failure. If a normal code is returned, the system will start the printing program, complete the printing of the UnionPay or payment institution's receipt, and the payment process ends.

[0014] Beneficial effects:

[0015] (1) The unified gateway authentication and identity authentication mechanism is adopted to ensure the security of platform information and funds, the convenience of user access operations, and greatly reduce the risk control of platform funds and sensitive information;

[0016] (2) Simplify the complexity of calling each other between internal services;

[0017] (3) Lightweight implantability;

[0018] (4) High safety factor;

[0019] (5) Wide range of applications;

[0020] (6) The use of both soft and hard encryption technology ensures the security of the platform’s communications and information transmission;

[0021] (7) Supports multiple system deployment scenarios with and without network isolation;

[0022] (8) Ensure the security of data transmission during credit data sharing and exchange through hybrid encryption mode;

[0023] (9) The load balancer is allocated to the service node according to the strategy, ensuring that the load balancer can truly and accurately obtain the real-time processing capacity of the service node and avoid the impact of the real-time parameter process on the performance of the system; BRIEF DESCRIPTION OF THE DRAWINGS

[0024] Figure 1 This is a flow chart of the payment link automatic switching method of the present invention;

[0025] Figure 2 It is a timing diagram of the payment link automatic switching method of the present invention; DETAILED DESCRIPTION

[0026] The present invention will be further described below in conjunction with the accompanying drawings and embodiments.

[0027] A payment link automatic switching method,

[0028] S1. The user logs in to the platform through the service gateway, prepares to make a payment, monitors the POS machine status, and enters S2 if it is in the startup state. Otherwise, the payment channel service does not start, and the user is prompted to start the machine;

[0029] S2. Wake up and enable the payment channel monitoring service, call the interface and return the available payment channels;

[0030] S3. Monitor the payment channel status, scan the payment channel port regularly, and return the status code: the payment monitoring service scans the current payment channel interface at an interval (every 5 seconds, the interval is configurable), returns the status code of each payment channel (000 indicates that the channel is normal, and other status codes indicate that the payment channel is abnormal), and puts all status codes into the payment channel cache;

[0031] S4. List available payment channels and select the default payment channel: the system automatically selects the default normal payment channel. If all payment channels are unavailable, a warning will be displayed directly on the POS interface, indicating that payment cannot be made normally.

[0032] S5. Select the payment channel and prepare to pay. The user swipes the card, pays by QR code, and enters the verification password;

[0033] S7. Scan the payment channel and place the available information in the cache;

[0034] S8. The payment channel is read from the cache, and the payment monitoring service scans the payment channel interface at intervals. If the payment channel currently used by the user has an exception, it checks whether there are other available payment channels. If not, it prompts the user that payment is currently unavailable. Otherwise, it automatically switches to an available payment channel, and obtains the information that the user has selected and entered in the context, and seamlessly switches to the service of the newly selected payment channel. The user completes the payment on the new channel without the user being aware of it.

[0035] S9. Exception code processing and receipt printing: If UnionPay or the payment institution does not return a normal payment success code within the valid time, or returns an exception code, and the system scans that the current POS machine has an exception payment code or does not return after a timeout, the user will be informed that the payment was not successful. UnionPay or the payment institution will complete the fund reconciliation and refund operations within an appropriate period of time, and change the current payment order status to payment failure. If a normal code is returned, the system will start the printing program, complete the printing of the UnionPay or payment institution's receipt, and the payment process ends.

[0036] Among them, the timing process of automatic switching is as follows:

[0037] S1. The scheduled thread task scans the payment channel in the cache every 2 seconds to see if it is in a healthy state;

[0038] S2.Pos machine initialization, request to load corresponding parameters, and encrypt some sensitive information;

[0039] S2.1. Start the main program of the Pos machine attached to the Netty client, and the server service is started at the same time, creating or maintaining the limitation of the connection channel;

[0040] S2.2. Monitor the main thread and monitor the increase, decrease, invalidation, normal and other status of the payment channel;

[0041] S3. Check whether the payment channel thread is alive by monitoring the payment channel port;

[0042] S3.1 Initiate the connection of the payment channel;

[0043] S3.2 For ports with connection timeout or failure, the port reconnection mechanism is started in real time;

[0044] S4. Check the status of the payment channel by checking the port's survival;

[0045] S4.1. For payment channels that are alive or healthy through port checks, put them into the cache queue and wait for checking and activation;

[0046] S5. The front end requests the payment channel to complete the transaction;

[0047] S5.1. Return one of the currently valid payment channels for the current payment.

[0048] S6. When the valid payment channel is used normally, the platform will send an in-site message notification.

[0049] S7. Return the payment transaction result to the platform through the transaction process of the current payment channel.

[0050] S7.1. Return the transaction data of the payment channel.

[0051] S8. The platform obtains payment data and payment status returned by the payment institution, and completes payment channel selection and payment transaction results.

[0052] The data sharing cluster uses the distributed cache / data synchronization technology Redis. All payment channels will be stored in Redis. Distributed deployment supports the management of multi-node payment channels and effective node loading access, and the data synchronization mechanism ensures the consistency and validity of data between master and slave nodes.

[0053] Redis is a high-performance storage system related to memory-based, persistent log and Key-Value databases. It provides APIs in multiple languages ​​and achieves uniform distribution of Redis nodes corresponding to keys by performing consistent hashing on keys. All access requests to Redis are evenly distributed to all deployed Redis valid nodes through the consistent hashing algorithm.

[0054] Among them, the consistent hashing algorithm means: to determine which server an object should be cached on, map the cache server and the cached object to the hash ring, and start from the location of the cached object, and the first server encountered in the clockwise direction is the server where the current object will be cached. Since the hashed values ​​of the cached object and the server are fixed, an object will definitely be cached on a fixed server if the deployment server remains unchanged. Then, when the object is accessed next time, just use the same algorithm to calculate again to calculate which server the object is cached on, and directly go to the corresponding server to search;

[0055] Data synchronization through Redis: Redis master-slave synchronization mechanism can ensure data synchronization between Redis master (primary node) and slave (slave node). According to the amount of synchronization content, it can be divided into full synchronization and partial synchronization, specifically:

[0056] Initialize full synchronization: When the slave starts, it will send a SYNC message to its master. After receiving the message from the slave, the master may start the background process to perform backup. After the backup is completed, the backup data will be sent to the slave.

[0057] Data modification synchronization: After the initialization of the entire synchronization operation is completed, all subsequent write operations are performed on the master, and all read operations are performed on the slave. The user's write operations need to be spread to all slaves in a timely manner to keep the data synchronized to the greatest extent.

[0058] Among them, the POS machine is connected to the server through a load balancer. Sentinel is integrated with the mainstream framework SpringCloud (Spring service suite) through an adapter. Sentinel's related current limiting and degradation codes are added to the extension point of SpringCloud. When one or several servers in the cluster are overloaded or fail to respond in time for a long time, the Sentinel fuse mechanism is enabled, thereby achieving the purpose of protecting the high stability and high availability of the automatic switching service of the payment link;

[0059] Sentinel is a lightweight, highly available access flow control component for distributed service architecture. It mainly uses access flow as the entry point to protect the stability of automatic switching services in payment links from multiple dimensions such as access flow control, circuit breaker degradation, and system load protection.

[0060] Sentinel forms a linked list based on multiple (7) different service nodes. Each service node has its own responsibilities. After completing its own tasks, it will pass the request to the next service node until the service of a certain service node meets the current limiting and fuse conditions, and then throws a blocking exception to terminate the transmission. Sentinel completes the call to the entry method of each service node through the service node chain. Each service node will perform its own logical processing according to the created rules. When the statistical result reaches the set threshold, it will trigger the current limiting and fuse events; for example, throwing a blocking exception.

[0061] The functional responsibilities of the 7 nodes are as follows:

[0062] 1.NodeSelectorSlot is responsible for collecting resource paths and storing the call paths of these resources in a tree structure for limiting and degrading traffic based on the call paths.

[0063] 2. ClusterBuilderSlot is used to store resource statistics and caller information, such as RT (running time), QPS (queries per second), and threadcount (number of threads). This information will be used as the basis for multi-dimensional flow control and degradation.

[0064] 3.StatistcSlot is used to record and count the RunTime information at different latitudes.

[0065] 4. FlowSlot is used to limit the flow according to the preset flow limiting rules and the status of the previous node statistics.

[0066] 5. AuthorizationSlot performs blacklist and whitelist control based on the blacklist and whitelist.

[0067] 6. DegradeSlot uses statistical information and preset rules to perform circuit breaker downgrade.

[0068] 7. SystemSlot controls the total inlet flow through the system status.

[0069] The first three nodes are responsible for statistics, and the following four nodes are responsible for specific control based on the statistical results and the configured rules, determining whether to block or release the request.

[0070] Among them, the monitoring payment channel adopts two modes: Kafka polling and Listenene active push.

[0071] Kafka is used for message notification: caching message notifications on whether the payment link port is valid, refreshing message status and message expiration time, etc.; log collection: Kafka can be used to collect logs of various services, and open them to various consumers through Kafka in the form of a unified interface service.

[0072] Kafka is a distributed, partition-supported, multi-replica-based distributed messaging system coordinated by Zookeeper that can process large amounts of data in real time to meet various demand scenarios.

[0073] Kafka features:

[0074] 1. High throughput and low latency: Kafka can process hundreds of thousands of messages per second, and its minimum latency is only a few milliseconds.

[0075] 2. Scalability: Kafka cluster supports hot expansion.

[0076] 3. Persistence and reliability: Messages are persisted to local disks and support data backup to prevent data loss

[0077] 4. Fault tolerance: Allow nodes in the cluster to fail.

[0078] 5. High concurrency: supports thousands of clients reading and writing at the same time.

[0079] Listener is independent of the development process. It listens to Kafka messages by using the @KafkaListener annotation and then consumes them in this method. You don’t need to care about the specific implementation of Kafka. You only need to add a topic to the configuration value file.

[0080] Polling is the core of the Kafka consumer API. Through a simple polling, data is requested from the server. Once the consumer subscribes to a topic, polling will handle all the details, including group coordination, partition rebalancing, sending heartbeats, and obtaining data. Developers only need to use a set of simple APIs to process the data returned from the partitions.

[0081] Among them, the effective payment channel is enabled. During its initialization process, a communication relationship is established with the corresponding payment channel through a Socket long link to obtain relevant parameters of the current device and obtain relevant data from the interface of the platform server. The IO processing is performed by Nio. Netty's Socket long connection and Nio's unimpeded transmission ensure that the service communication is unblocked;

[0082] Netty uses socket long connection to save a lot of TCP establishment / closing operations, reduce waste, save time, and is more suitable for long connections for users who frequently request resources. If the client and server are not closed for a long time, there will be a problem: as more and more users come, the server's resources will be consumed.

[0083] The shortcomings of long connections can be solved by establishing a distribution server. The specific solution is as follows:

[0084] 1. The device requests the distribution server, which returns a valid socket server IP and port, and then disconnects;

[0085] 2. After the device obtains the IP and port, it connects to the socket server and then communicates with it via protocol;

[0086] 3. If the device does not receive a successful connection response, it will try to connect again. If the connection is still not established successfully after three requests, the device needs to request the distribution server and then repeat the above operation.

[0087] 4. It can easily solve the problem of frequent communication between devices and servers.

[0088] Nio is a non-blocking IO processing mode, which mainly consists of three core parts: Channel, Buffer, and Selector. Traditional IO operates based on byte stream and character stream, while Nio operates based on Channel and Buffer. Data is always read from the channel to the buffer, or written from the buffer to the channel. Selector is used to monitor events of multiple channels. A single thread can monitor multiple data channels.

[0089] Among them, distributed transaction components are used: Seata and RocketMQ are used to maintain the integrity of payment transaction loop transactions, Seata and RocketMQ are used to monitor the status of payment channel ports, complete message notifications, status updates, send and receive local transaction messages through messages, and at the same time, Seata and RocketMQ are used to implement transaction control for independent data updates between multiple services.

[0090] Seata is a distributed transaction framework that can handle synchronous transactions. The application layer implements automatic compensation based on SQL parsing, thereby minimizing business intrusion. The TC (transaction coordinator) in the distributed transaction is deployed independently, responsible for transaction registration and rollback. Write isolation and read isolation are achieved through global locks.

[0091] RocketMQ is an AMQ message middleware product. It is a distributed, queue-based message middleware that handles asynchronous distributed transaction processing and message processing. It can ensure strict message order, provide rich message pull modes, efficient subscriber horizontal expansion capabilities, real-time message subscription mechanism, and billion-level message accumulation capabilities; it provides docker images for isolated testing and cloud cluster deployment; it provides a dashboard with rich functions such as configuration, indicators, and monitoring.

[0092] Among them, message notifications are automatically pushed through Netty and RocketMQ. Netty and RocketMQ monitor the payment channel port status, complete message notifications, status updates, send and receive local transaction messages, send business message notifications, and consume business message processing through messages;

[0093] Netty is an asynchronous event-driven network application framework that supports the rapid development of maintainable, high-performance, protocol-oriented servers and clients. Netty encapsulates Nio's API and improves performance to a certain extent in the following ways: multiplexing improves the concurrency of processing connections. Netty uses direct caching for receiving and sending data, and uses off-heap direct memory for Socket reading and writing, without the need for secondary copying of byte buffers. RocketMQ's underlying RPC communication uses the Netty framework.

[0094] In this case application:

[0095] Among them, the automatic switching of the payment link integrates the payment interfaces of multiple payment channels and adopts seamless and delay-free automatic switching technology, which ensures the real-time and convenience of the payment channel and the security of user payment funds.

[0096] The automatic payment link switching technology means that when a user pays with a POS machine, the system will automatically select the most appropriate payment channel to complete the current payment operation based on the status of the current payment channel. It is reflected in the comprehensive integration of key technologies such as Redis, Kafka, Sentinel, Netty, Seata, RocketMQ, and GPE.

[0097] Among them, GPE is used to monitor the gateway payment routing, gateway payment channel, gateway payment port and interface services of hardware devices. GPE implements early warning mechanism and heartbeat detection mechanism;

[0098] GPE is the abbreviation of Grafana, Prometheus, and Exporter. Grafana is an out-of-the-box visualization tool. Prometheus is an open source service monitoring system that collects data from remote machines through the HTTP protocol and stores it in a local time series database. Exporter is an important component of Prometheus monitoring, responsible for collecting data indicators and deployed on the user side.

[0099] The GPE workflow is as follows: the Exporter component is registered with the registration center; Prometheus pulls the server in the registration center; the Exporter component obtains the indicators of the server or system software; Grafana configures the Prometheus data source to obtain its collected data and combines it with the custom panel to realize the monitoring screen; Grafana realizes monitoring and early warning by setting Alerting.

[0100] Among them, users log in to the platform through the service gateway, and the service gateway performs gateway flow control through SC Gateway and passes JWT / Oauth2 authentication. SC Gateway refers to Spring Cloud Gateway service gateway. Spring CloudGateway is a new gateway framework launched by Spring Cloud. The gateway is usually used in the project to simplify the front-end calling logic and also to simplify the complexity of calling each other between internal services. Its specific function is to forward services, receive and forward all internal and external user-side calls. Other common functions include permission authentication, flow control, etc.

[0101] JWT (JSON Web Token) is an open standard (RFC 7519) that defines a protocol for securely transmitting information between two points in a self-contained JSON format. The information being transmitted can be verified and trusted because it uses a digital signature. JWT can be digitally signed using a public / private key pair algorithm. Oath2 itself is an authorization protocol.

[0102] The public key / secret key pair algorithm introduces two classic encryption algorithms, namely the iterative block encryption algorithm and the asymmetric encryption algorithm, and combines the advantages of the two to realize credit data exchange and transmission based on a hybrid encryption mode of the above two encryption algorithms, so as to ensure the security of data transmission during the credit data sharing and exchange process.

[0103] Among them, the public key / secret key pair algorithm is specifically:

[0104] S1: Use the iterative block encryption algorithm to encrypt the plaintext P to be transmitted to form a ciphertext;

[0105] S2: Generate a pair of secret keys using an asymmetric encryption algorithm. The sender uses the public key generated by the asymmetric encryption algorithm to encrypt the secret key of the iterative block encryption algorithm, and sends the secret key of the iterative block encryption algorithm encrypted by the asymmetric encryption algorithm and the ciphertext encrypted by the iterative block encryption algorithm to the receiver.

[0106] S3: The receiver uses the private key generated by the asymmetric encryption algorithm to decrypt the secret key of the iterative block encryption algorithm encrypted by the asymmetric encryption algorithm, and then uses the secret key of the iterative block encryption algorithm to decrypt the ciphertext to form plaintext, thereby achieving the purpose of secure transmission.

[0107] The iterative block encryption algorithm is as follows:

[0108] The iterative block encryption algorithm generates 64 bits of ciphertext while processing 64 bits of information plaintext blocks. In the iterative block encryption algorithm, eight bits are used as check bits, namely the 8th, 16th, 24th, 32nd, 40th, 48th, 56th, and 64th bits, and the effective number of bits of the secret key used for encryption is 56 bits.

[0109] From 64-bit plaintext data input to 64-bit ciphertext output, the iterative block encryption algorithm performs 16 rounds of encryption. In each round of encryption, there is a 48-bit secret key K i and 8 alternative mapping boxes S i Participate in it, split the input 64-bit plaintext data into two identical and independent 32-bit plaintexts, recorded as L0 and R0, and perform round encryption with the same algorithm in each round, using the 32-bit L0 of the previous round i-1 With R i-1 As input parameter, the output 32-bit parameter is L i and R i , where the value range of i is 1≤i≤16.

[0110] The specific steps of each round of encryption calculation method are as follows:

[0111] S1. Input 64-bit data;

[0112] S2. Initial replacement IP;

[0113] S3. Encryption, L i =R i-1 ,

[0114] S4. Final replacement IP -1 .

[0115] Among them, f(R i-1 ,K i ) represents the mapping box algorithm, K i represents the key of round i, represents XOR operation, E() and P() represent expansion function and mapping function respectively, E() and P() are used to calculate R i-1 and Perform bit expansion mapping to expand 32 bits to 48 bits. For iterative block encryption algorithms, the initial replacement IP and the final replacement IP -1 There are corresponding rules for position replacement and arrangement;

[0116] Among them, the mapping box algorithm f(R i-1 ,K i )The specific implementation is as follows:

[0117] S1. R i-1 =r1r2r3.......r32 Expanded from 32 bits to 48 bits, R i-1 represents the ciphertext after i-1 rounds of encryption of the plaintext, r i Indicates the character at position i;

[0118] S2. R i-1 To expand, T1 represents eight 6-bit strings B i , T1=B1B2......B8;

[0119] S3.(S1(B1),S2(B2),...,S8(B8))→T2, where S i (B i ) i = b1b2......b6, mapped to mapping box S i The 4 bits of row r and column c of the 4-bit digit, where r = 2b1 + b6, b2b3b4b5 is the binary representation of 0 ≤ c ≤ 15, b i For string B i The i-th character of ;

[0120] S4. The permutation function P() is used to permute T2, which is recorded as P(T2)→T3. By directly transposing, the 32-bit T2=t1t2......t 32 Replace with T2 = t 16 t7......t 25 .

[0121] Among them, the secret key K of the iterative block encryption algorithm i It is composed of 48-bit password length, 16 rounds of iterations, each iteration requires a different secret key K i Encryption, secret key K i The generation process is as follows:

[0122] S1. Remove 8 key parity check bits, reduce the 64-bit initial key K0 to 56 bits, and divide the 56-bit key into two parts according to the key permutation selection, namely 28 bits C0 and 28 bits D0;

[0123] S2. Circularly shift C0 and D0 to the left according to the rounds, generate C1 and D1 after transformation, then merge C1 and D1, and then generate a 48-bit secret key K1 through secret key permutation;

[0124] S3. Perform circular left shift transformation on C1 and D1 again to generate C2 and D2, and then merge C1 and D1 to generate a 48-bit secret key K2 by selective permutation;

[0125] S4. Repeat step S3 9 times to get the 48-bit secret key K i , 3≤i≤16.

[0126] The number of bits of the circular left shift is determined by the number of iterations. The 1st, 2nd, 9th, and 16th rounds are shifted left by one bit, and the remaining rounds are shifted left by two bits.

[0127] The asymmetric encryption algorithm steps are as follows:

[0128] S1. Select two large prime numbers p and q, and require p≠q, calculate, then n = p × q;

[0129] S2. Select a prime number e and require e to satisfy and the greatest common divisor

[0130] S3. Calculation mod represents the remainder function;

[0131] S4. Publish the secret key and K public =(e,n) is used as the public key parameter, K private =(d,n) is used as private key parameters;

[0132] S5. Using C=p e The modn formula encrypts the plaintext, p = C d The modn formula is used to decrypt the ciphertext; where the binary digits of the prime numbers p and q are greater than 1024, and the decimal values ​​of the prime numbers p and q satisfy 1000<|pq|<10000,

[0133] Among them, the load balancer distributes the request tasks to the service nodes according to a certain strategy. In order to ensure that the load balancer can truly and accurately obtain the real-time processing capacity of the service nodes, it is necessary to analyze the factors that affect the processing capacity of the service nodes. When the load balancing module collects parameters of the service nodes, if there are too many parameters, it will cause certain resource loss to the load balancing nodes and service nodes. In order to avoid the impact of the real-time parameter collection process of the service nodes on the performance of the system, it is decided to use the two main core factors that affect the server nodes as indicators of real-time load capacity, namely processor utilization and memory idle rate.

[0134] The steps include:

[0135] S1. The communication between the load balancer and the service node is implemented using the Socket interface. To reduce the resource loss caused by communication, UDP, which has less resource requirements, is used as the transmission protocol;

[0136] S2. The load balancer periodically sends collection requests to the service node and calculates the processor utilization and memory idle rate of the service node;

[0137] The processor is divided into three operating states: idle state, user state and system kernel state. T1 represents the running time of idle state, T2 represents the running time of user state, and T3 represents the running time of kernel state. The processor utilization C i The calculation formula is as follows:

[0138]

[0139] Through the system file, you can find out the total memory size of the current service node, the buffer size, the cached size, the free memory size, and the memory idle rate M i The calculation formula is as follows:

[0140]

[0141] S3. Calculate the service node weight.

[0142] For multiple service nodes N i , using the set Node={N1,N2,...,N i ,...,N n} means that for service node N i The processor utilization is expressed in C i Indicates that the memory idle rate is expressed in M i Indicated by W i Indicates that the service node N i The weight expression function F i As follows: F i =λ1(1-C i )+λ2M i ;

[0143] Where λ1+λ2=1, λ1 and λ2 represent the influence factors of processor and memory, C i and M i The values ​​of are all in the range [0,1]. i and M i When both are 0, F i If it is 0, it means that the service node is unavailable and no tasks will be assigned to it. When the load weight difference is met, W i =F i ;

[0144] Among them, preferably λ1=0.6, λ2=0.4;

[0145] S4. The new weight value and the old value are subjected to boundary condition analysis. Under the boundary value P, for the service node weight W i The update must satisfy the following formula:

[0146] Among them, 0<P<1,

[0147] When the boundary conditions are met, the setsockopt function is called to write the new weight into the load configuration table of the load balancer and redistribute the load tasks. Otherwise, the tasks are forwarded and distributed according to the previous load balancing.

[0148] The above-described embodiment only expresses one embodiment of the present invention, but it should not be understood as limiting the scope of the present invention. It should be pointed out that for ordinary technicians in this field, several modifications and improvements can be made without departing from the concept of the present invention, which all belong to the protection scope of the present invention.

Claims

1. A payment link automatic switching method, comprising the following steps: S1. The user logs in to the platform through the service gateway, prepares to make a payment, monitors the POS machine status, and enters S2 if it is in the startup state. Otherwise, the payment channel service does not start, and the user is prompted to start the machine; S2. Wake up and enable the payment channel monitoring service, call the interface and return the available payment channels; S3. Monitor the payment channel status, scan the payment channel port regularly, and return the status code: the payment monitoring service scans the current payment channel interface at intervals, returns the status code of each payment channel, and puts all the status codes into the payment channel cache; S4. List available payment channels and select the default payment channel: the system automatically selects the default normal payment channel. If all payment channels are unavailable, a warning will be displayed directly on the POS interface, indicating that payment cannot be made normally. S5. Select the payment channel and prepare to pay. The user swipes the card, pays by QR code, and enters the verification password; S7. Scan the payment channel and place the available information in the cache; S8. The payment channel is read from the cache, and the payment monitoring service scans the payment channel interface at intervals. If the payment channel currently used by the user has an exception, it checks whether there are other available payment channels. If not, it prompts the user that payment is currently unavailable. Otherwise, it automatically switches to an available payment channel, and obtains the information that the user has selected and entered in the context, and seamlessly switches to the service of the newly selected payment channel. The user completes the payment on the new channel without the user being aware of it. S9. Exception code processing and receipt printing: If UnionPay or the payment institution does not return a normal payment success code within the valid time, or returns an exception code, and the system scans the current POS machine for an exception payment code or does not return after a timeout, the user will be informed that the payment was unsuccessful. UnionPay or the payment institution will complete the fund reconciliation and refund operations within a reasonable period, and change the current payment order status to payment failure. If a normal code is returned, the system will start the printing program, complete the receipt printing of UnionPay or the payment institution, and the payment process ends; S1. The scheduled thread task scans the payment channel in the cache every 2 seconds to see if it is in a healthy state; S2.Pos machine initialization, request to load corresponding parameters, and encrypt some sensitive information; S2.

1. Start the main program of the Pos machine attached to the Netty client, and the server service is started at the same time, creating or maintaining the limitation of the connection channel; S2.

2. Monitor the main thread and monitor the increase, decrease, invalidation and normal status of the payment channel; S3. Check whether the payment channel thread is alive by monitoring the payment channel port; S3.1 Initiate the connection of the payment channel; S3.2 For ports with connection timeout or failure, the port reconnection mechanism is started in real time; S4. Check the status of the payment channel by checking the port's survival; S4.

1. For payment channels that are alive or healthy through port checks, put them into the cache queue and wait for checking and activation; S5. The front end requests the payment channel to complete the transaction; S5.

1. Return one of the currently valid payment channels for current payment; S6. When the valid payment channel is used normally, the platform will send an in-site message notification; S7. Return the result of the payment transaction to the platform through the transaction process of the current payment channel; S7.

1. Return the transaction data of the payment channel; S8. The platform obtains payment data and payment status returned by the payment institution, completes payment channel selection and payment transaction results; The public key / secret key pair algorithm introduces two classic encryption algorithms to realize the credit data exchange and transmission based on the hybrid encryption mode of the above two encryption algorithms. The public key / secret key pair algorithm is specifically: S1: Use the iterative block encryption algorithm to encrypt the plaintext P to be transmitted to form a ciphertext; S2: Generate a pair of secret keys using an asymmetric encryption algorithm. The sender uses the public key generated by the asymmetric encryption algorithm to encrypt the secret key of the iterative block encryption algorithm, and sends the secret key of the iterative block encryption algorithm encrypted by the asymmetric encryption algorithm and the ciphertext encrypted by the iterative block encryption algorithm to the receiver. S3: The receiver uses the private key generated by the asymmetric encryption algorithm to decrypt the secret key of the iterative block encryption algorithm encrypted by the asymmetric encryption algorithm, and then uses the secret key of the iterative block encryption algorithm to decrypt the ciphertext to form plaintext, thereby achieving the purpose of secure transmission; The iterative block encryption algorithm is as follows: The iterative block encryption algorithm generates 64 bits of ciphertext while processing 64 bits of information plaintext blocks; in the iterative block encryption algorithm, eight bits are used as check bits, namely the 8th, 16th, 24th, 32nd, 40th, 48th, 56th, and 64th bits, and the effective number of bits of the secret key used for encryption is 56 bits; From 64-bit plaintext data input to 64-bit ciphertext output, the iterative block encryption algorithm performs 16 rounds of encryption. In each round of encryption, there is a 48-bit secret key K i and 8 alternative mapping boxes S i Participate in it, split the input 64-bit plaintext data into two identical and independent 32-bit plaintexts, recorded as L0 and R0, and perform round encryption with the same algorithm in each round, using the 32-bit L0 of the previous round i-1 With R i-1 As input parameter, the output 32-bit parameter is L i and R i , where the value range of i is 1≤i≤16; The specific steps of each round of encryption calculation method are as follows: S1. Input 64-bit data; S2. Initial replacement IP; S3. Encryption, L i =R i-1 , S4. Final replacement IP -1 ; Among them, f(R i-1 ,K i ) represents the mapping box algorithm, K i represents the key of round i, represents XOR operation, E() and P() represent expansion function and mapping function respectively, E() and P() are used to calculate R i-1 and Perform bit expansion mapping to expand 32 bits to 48 bits; for iterative block encryption algorithms, the initial replacement IP and the final replacement IP -1 There are corresponding rules for position replacement and arrangement; Among them, the mapping box algorithm f(R i-1 ,K i )The specific implementation is as follows: S1. R i-1 =r1r2r3.......r 32 Expanded from 32 bits to 48 bits, R i-1 represents the ciphertext after i-1 rounds of encryption of the plaintext, r j Indicates the character at position j; S2. R i-1 To expand, T1 represents eight 6-bit strings B i , T1=B1B2......B8; S3.(S1(B1),S2(B2),...,S8(B8))→T2, where S i (B i ) i = b1b2......b6, mapped to mapping box S i The 4 bits of row r and column c of the 4-bit digit, where r = 2b1 + b6, b2b3b4b5 is the binary representation of 0 ≤ c ≤ 15, b i For string B i The i-th character of ; S4. The permutation function P() is used to permute T2, which is recorded as P(T2)→T3. By directly transposing, the 32-bit T2=t1t2......t 32 Replaced by T3 = t 16 t7......t 25 ; Among them, the secret key K of the iterative block encryption algorithm i It is composed of 48-bit password length, 16 rounds of iterations, each iteration requires a different secret key K i Encryption, secret key K i The generation process is as follows: S1. Remove 8 key parity check bits, reduce the 64-bit initial key K0 to 56 bits, and divide the 56-bit key into two parts according to the key permutation selection, namely 28 bits C0 and 28 bits D0; S2. Circularly shift C0 and D0 to the left according to the rounds, generate C1 and D1 after transformation, then merge C1 and D1, and then generate a 48-bit secret key K1 through secret key permutation; S3. Perform circular left shift transformation on C1 and D1 again to generate C2 and D2, and then merge C1 and D1 to generate a 48-bit secret key K2 by selective permutation; S4. Repeat step S3 9 times to get the 48-bit secret key K i , 3≤i≤16; The number of bits of the circular left shift is determined by the number of iterations. The 1st, 2nd, 9th, and 16th rounds are shifted left by one bit, and the rest of the rounds are shifted left by two bits. The asymmetric encryption algorithm steps are as follows: S1. Select two large prime numbers p and q, and require p≠q, calculate, then n = p × q; S2. Select a prime number e and require e to satisfy and the greatest common divisor S3. Calculation mod represents the remainder function; S4. Publish the secret key and K public =(e,n) is used as the public key parameter, K private =(d,n) is used as private key parameters; S5. Using C=p e The modn formula encrypts the plaintext, p = C d The modn formula is used to decrypt the ciphertext; where the binary digits of the prime numbers p and q are greater than 1024, and the decimal values ​​of the prime numbers p and q satisfy 1000<|pq|<10000, The POS machine is connected to the server through a load balancer. Sentinel is integrated with the mainstream framework SpringClou through an adapter. Sentinel-related current limiting and degradation codes are added to the extension point of Spring Cloud. When one or several servers in the cluster are overloaded or fail to respond in time for a long time, the Sentinel fuse mechanism is enabled, thereby achieving the purpose of protecting the high stability and high availability of the automatic switching service of the payment link; Sentinel is a lightweight, highly available access flow control component for distributed service architecture. It mainly uses access flow as the entry point to protect the stability of automatic switching services in payment links from multiple dimensions, including access flow control, circuit breaker degradation, and system load protection. Sentinel forms a linked list based on 7 different service nodes. Each service node performs its own duties. After completing its own tasks, it will pass the request to the next service node until the service of a certain service node meets the current limiting and fuse conditions, and then throws a blocking exception to terminate the transmission. Sentinel completes the call to the entry method of each service node through the service node chain. Each service node will perform its own logical processing according to the created rules. When the statistical result reaches the set threshold, it will trigger the current limiting and fuse events. The functions and responsibilities of the seven types of nodes are as follows: NodeSelectorSlot is responsible for collecting resource paths and storing the call paths of these resources in a tree structure for limiting and degrading traffic based on the call paths. ClusterBuilderSlot is used to store resource statistics and caller information, including RT running time, QPS queries per second, and thread count. This information will be used as the basis for multi-dimensional flow control and degradation. StatistcSlot is used to record and count the RunTime information at different latitudes; FlowSlot is used to limit the flow according to the preset flow limiting rules and the status of the previous node statistics; AuthorizationSlot performs blacklist and whitelist control based on the blacklist and whitelist; DegradeSlot uses statistical information and preset rules to perform circuit breaker downgrade; SystemSlot controls the total ingress traffic through the system status; The first three nodes are responsible for statistics, and the following four nodes are responsible for specific control based on the statistical results and the configured rules, whether to block or release the request; Among them, the load balancer distributes the request tasks to the service nodes according to a certain strategy. In order to ensure that the load balancer can truly and accurately obtain the real-time processing capacity of the service nodes, it is necessary to analyze the factors that affect the processing capacity of the service nodes; when the load balancing module collects parameters of the service nodes, if there are too many parameters, it will cause certain resource loss to the load balancing nodes and service nodes; in order to avoid the impact of the real-time parameter collection process of the service nodes on the performance of the system, it is decided to use the two main core factors that affect the server nodes as indicators of real-time load capacity, namely processor utilization and memory idle rate; The steps include: S1. The communication between the load balancer and the service node is implemented using the Socket interface. To reduce the resource loss caused by communication, UDP, which has less resource requirements, is used as the transmission protocol; S2. The load balancer periodically sends collection requests to the service node and calculates the processor utilization and memory idle rate of the service node; The processor is divided into three operating states: idle state, user state and system kernel state, which are indicated by T a Indicates the idle state running time, T b Indicates the running time of user mode, T c represents the running time of kernel state, then the processor utilization C i The calculation formula is as follows: Through the system file, you can find out the total memory size of the current service node, the buffer size, the cached size, the free memory size, and the memory idle rate M i The calculation formula is as follows: S3. Calculate the service node weight. For multiple service nodes N i , using the set Node={N1,N2,...,N i ,...,N n } means that for service node N i The processor utilization is expressed in C i Indicates that the memory idle rate is expressed in M i Indicated by W, the weight i Indicates that the service node N i The weight expression function F i As follows: F i =λ1(1-C i )+λ2M i ; Where λ1+λ2=1, λ1 and λ2 represent the influence factors of processor and memory, C i and M i The values ​​of are all in the range [0,1]. i and M i When both are 0, F i If it is 0, it means that the service node is unavailable and no tasks will be assigned to it. When the load weight difference is met, W i =F i ; S4. The new weight value and the old value are subjected to boundary condition analysis. Under the boundary value P, for the service node weight W i The update must satisfy the following formula: Among them, 0<P<1, When the boundary conditions are met, the setsockopt function is called to write the new weight into the load configuration table of the load balancer and redistribute the load tasks. Otherwise, the tasks are forwarded and distributed according to the previous load balancing.

2. A payment link automatic switching method according to claim 1, characterized in that: The data sharing cluster uses the distributed cache / data synchronization technology Redis. All payment channels will be stored in Redis. Distributed deployment supports the management of multi-node payment channels and effective node loading access. The data synchronization mechanism ensures the consistency and validity of data between master and slave nodes. Redis is a high-performance storage system related to memory-based, persistent log and Key-Value databases. It provides APIs in multiple languages ​​and achieves uniform distribution of Redis nodes corresponding to keys by performing consistent hashing on keys. All access requests to Redis are evenly distributed to all deployed Redis valid nodes through the consistent hashing algorithm. The consistent hashing algorithm refers to: determining which server an object should be cached on, mapping both the cache server and the cached object to the hash ring, starting from the location of the cached object, and the first server encountered in a clockwise direction is the server where the current object will be cached. Since the hashed values ​​of the cached object and the server are fixed, an object will definitely be cached on a fixed server if the deployment server remains unchanged. Then, when the object is accessed next time, the same algorithm can be used to calculate again to find out which server the object is cached on, and the corresponding server can be searched directly. Data synchronization through Redis: Redis master-slave synchronization mechanism can ensure data synchronization between Redis master node and slave node; according to the amount of synchronization content, it is divided into full synchronization and partial synchronization, specifically: Initialize full synchronization: When the slave starts, it will send a SYNC message to its master. After receiving the message from the slave, the master may start the background process to perform backup. After the backup is completed, the backup data will be sent to the slave. Data modification synchronization: After the initialization of the entire synchronization operation is completed, all subsequent write operations are performed on the master, and all read operations are performed on the slave. The user's write operations need to be spread to all slaves in a timely manner to keep the data synchronized to the greatest extent.

3. A payment link automatic switching method according to claim 1, characterized in that: The payment channel monitoring adopts two modes: Kafka polling and Listenene active push. Kafka is used for message notification: caching payment link port validity notification, refreshing message status and message expiration time; log collection: Kafka can be used to collect logs of various services and open them to various consumers through Kafka in the form of a unified interface service; Kafka is a distributed, partitioned, multi-copy distributed messaging system based on Zookeeper coordination, which can process large amounts of data in real time to meet various demand scenarios; Listener listens to Kafka messages by using the @KafkaListener annotation, and then consumes them in this method. You don’t need to care about the specific implementation of Kafka. You only need to add a topic to the configuration value file. Polling is the core of the Kafka consumer API. Through a simple polling, data is requested from the server. Once the consumer subscribes to a topic, polling will handle all the details, including group coordination, partition rebalancing, sending heartbeats, and obtaining data. Developers only need to use a set of simple APIs to process the data returned from the partitions.

4. A payment link automatic switching method according to claim 1, characterized in that: Enable a valid payment channel. During its initialization, establish a communication relationship with the corresponding payment channel through a Socket long link to obtain relevant parameters of the current device and obtain relevant data from the interface of the platform server. The IO processing is performed by Nio. Netty's Socket long connection and Nio's unimpeded transmission ensure that the service communication is unblocked. Netty uses socket long connection to save a lot of TCP establishment / closing operations, reduce waste, save time, and is more suitable for long connections for users who frequently request resources. If the client and server are not closed for a long time, there will be a problem: as more and more users come, the server's resources will be consumed. The shortcomings of long connections can be solved by establishing a distribution server. The specific solution is as follows: The device requests the distribution server, which returns a valid socket server IP and port, and then disconnects. After the device obtains the IP and port, it connects to the socket server and then communicates with it via protocol. If the device does not receive a successful connection response, it will try to connect again. If the connection is still not established successfully after three requests, the device needs to request the distribution server and then repeat the above operation; Nio is a non-blocking IO processing mode, which mainly consists of three core parts: Channel, Buffer, and Selector. Traditional IO operates based on byte streams and character streams, while Nio operates based on Channel and Buffer. Data is always read from the channel to the buffer, or written from the buffer to the channel. Selector is used to monitor events of multiple channels. A single thread can listen to multiple data channels.

5. A payment link automatic switching method according to claim 1, characterized in that: Distributed transaction components are used: Seata and RocketMQ are used to maintain the integrity of the payment transaction loop, Seata and RocketMQ are used to monitor the status of the payment channel port, complete message notification, status update, send and receive local transaction messages through messages, and use Seata and RocketMQ to implement transaction control for independent data updates between multiple services; Seata is a distributed transaction framework that can handle synchronous transactions. The application layer implements automatic compensation based on SQL parsing, thereby minimizing business intrusion. The TC in the distributed transaction is deployed independently, responsible for transaction registration and rollback. Write isolation and read isolation are achieved through global locks. RocketMQ is an AMQ message middleware product. It is a distributed, queue-based message middleware that handles asynchronous distributed transactions and message processing. It can ensure strict message order, provide a variety of message pull modes, efficient subscriber horizontal expansion capabilities, real-time message subscription mechanism, and billion-level message accumulation capabilities. Provides Docker images for isolated testing and cloud cluster deployment; provides a dashboard with rich configuration, metrics, and monitoring functions.

6. A payment link automatic switching method according to claim 1, characterized in that: Message notifications are automatically pushed through Netty and RocketMQ. Netty and RocketMQ monitor the status of the payment channel port, complete message notifications, status updates, send and receive local transaction messages, send business message notifications, and consume business message processing through messages; Netty is an asynchronous event-driven network application framework that supports the rapid development of maintainable, high-performance, protocol-oriented servers and clients. Netty encapsulates Nio's API and uses multiplexing to improve the concurrency of connection processing. Netty uses direct caching for receiving and sending data, and uses direct off-heap memory for Socket reading and writing, without the need for secondary copying of byte buffers. RocketMQ's underlying RPC communication uses the Netty framework.

7. A payment link automatic switching method according to claim 1, characterized in that: Use GPE to monitor gateway payment routing, gateway payment channels, gateway payment ports, and interface services of hardware devices. GPE implements early warning mechanisms and heartbeat detection mechanisms. GPE is the abbreviation of Grafana, Prometheus, and Exporter. Grafana is an out-of-the-box visualization tool. Prometheus is an open source service monitoring system that collects data from remote machines through the HTTP protocol and stores it in a local time series database. Exporter is an important component of Prometheus monitoring, responsible for collecting data indicators and deployed on the user side. The GPE workflow is as follows: the Exporter component is registered with the registration center; Prometheus pulls the server in the registration center; the Exporter component obtains the indicators of the server or system software; Grafana configures the Prometheus data source to obtain its collected data and combines it with the custom panel to realize the monitoring screen; Grafana realizes monitoring and early warning by setting Alerting.

8. A payment link automatic switching method according to any one of claims 1 to 7, characterized in that: The automatic switching of the payment link integrates the payment interfaces of multiple payment channels and adopts seamless and delay-free automatic switching technology. The automatic switching technology of the payment link means that when the user pays with the POS machine, the system will automatically select the most appropriate payment channel according to the status of the current payment channel to complete the current payment operation. It is reflected in the comprehensive integration of key technologies such as Redis, Kafka, Sentinel, Netty, Seata, RocketMQ, and GPE.