The invention relates to the field of communication technology, in particular to a method, a client device, a POS terminal and a storage medium for offline transaction.
Regarding mobile payment, the prior arts generally use Near Field Communication (NFC) for payment. However, the NFC configuration costs are high, and it's not very popular for mobile devices with NFC. Therefore, it is limited to pay by NFC.
In addition, other related technologies can be used for account top-up. There are two methods for carrying out top-up in general: First, the cardholder pays the merchant directly and provides account information to the merchant, and the merchant top-ups the corresponding account on the merchant's terminal. Second, the cardholder logs in to the online platform on his mobile device, connects to the server that provides the top-up service, and top-ups the corresponding account on the online platform. However, for the first one, the merchant is required to install a dedicated terminal. In the initial stage of the system deployment, the number of cardholders who use the payment platform is still small, and it is difficult to find enough merchants to install the terminal, which makes it difficult for the cardholder to find a place to top-up. For the second one, cardholders need to operate online during the top-up process. But, in some undeveloped countries, wireless network coverage is poor, and places that can be top-up are limited. Therefore, the second top-up cannot be widely used.
It is an object of the present invention to provide a method, a client device and a POS terminal for offline transaction to solve one or more of the technical problems set forth above in the prior art.
Embodiments of the present invention provide a method for offline transaction, executed by a client device, comprising:
Embodiments of the present invention provide a method for offline transaction, executed by a POS terminal, and comprising:
If the transaction token is valid, generating a new transaction record according to the transaction amount input by a merchant to the POS terminal and the last transaction record; wherein the valid state includes that the expiry date is later than the current time; and
Embodiments of the present invention provide a client device, comprising:
The memory module, further configured to store the new transaction record for perform the next transaction with a POS terminal.
Embodiments of the present invention provide a POS terminal, comprising:
Embodiments of the present invention also provide a computer readable storage medium storing a computer program. The method provided by any one of the above embodiments is implemented when the program is executed by a processor.
The embodiment of the invention can provide a safe and convenient implementation scheme for the offline transaction of the client phone user, and the card holder can conveniently perform the top-up without the merchant installing a dedicated terminal device. Moreover, the present invention can realize offline operation, and can perform top-up operation in places where wireless coverage is not good.
The invention will be described in detail below with reference to the drawings and embodiments.
As shown in
As shown in
As shown in
As shown in
The present invention provides an offline transaction method for a POS terminal including a two-dimensional code reader and a Bluetooth. The balance of the wallet can be recorded in the memory module of the mobile phone in a general ledger. The client phone logs into the payment platform through the Internet in advance. After the server of the payment platform authenticates the user profile, the transaction token is sent to the client phone. The memory module of the client phone records the received transaction tokens.
During the transaction between the client phone and the POS terminal, the client phone displays the above transaction token in a two-dimensional code for the POS terminal to read. If the client phone has made a transaction with any POS terminal after receiving the transaction token, the latest transaction record can also be transmitted through the two-dimensional code. After reading the two-dimensional code, the POS terminal generates the latest transaction record and transmits it to the client phone via Bluetooth. The client phone receives the transaction record and records it into the memory module.
In some embodiments, the transaction token described above may include an expiry date. The client phone can always trade offline with the POS terminal before the expiry date. Before the expiry date, the client phone needs to check the transaction record again with the payment server and re-acquire a new transaction token. The new transaction token can provide a new expiry date so that the client phone can continue to perform offline transactions with the POS terminal. After receiving the transaction record sent by the client phone, the payment server can check whether each transaction made by the card holder of the client phone has been sent through the POS terminal. If the POS terminal fails to send a few transaction records due to offline operation, the payment server may first store the transaction record sent by the client phone, and after receiving the transaction record of the card holder that has not previously been uploaded by the POS terminal, payment server can then compare the transaction records in the future. If all transactions made by the card holder have been sent by the POS terminal, the payment server can compare the transaction record sent by the client phone with the transaction record sent by the POS terminal. If it is confirmed that there is no conflict between the two sets of transaction records, a new transaction token can be generated. This new transaction token may include a new expiry date.
Therefore, the embodiment can implement the function of offline top-up, and the client phone can complete the top-up without the network connection.
In addition, in some embodiments, the offline top-up function can be implemented without the presence of POS terminal, and the client phone can complete the top-up when the top-up merchant does not have the terminal. details as follows:
The cardholder gives the cash and the card number to be top-up to the merchant who is eligible to perform top-up transaction; the merchant uses his own computer or mobile phone to log in to the merchant virtual card top-up platform, enters the top-up amount and the card number; after the platform server processes the data, the POS terminal can downloads the latest top-up command list from the server and stores the top-up command list in the top-up command list memory module 105.
Thus, when the card holder makes a consumer transaction with any POS terminal through the client phone, the POS terminal can search for the top-up command from the top-up command list memory module 105. If the POS terminal has found the top-up command belonging to the virtual card ID of the client phone, the top-up action is completed simultaneously in the same communication session with the consumer transaction. That is, the balance of the wallet in the client phone is updated.
In some embodiments, in the offline case, if the transaction record of the client device not present top-up transaction is not sent to the payment server in time, it is likely to cause repeated execution of the same top-up command. In order to avoid this circumstance, the POS terminal can prevent the same top-up command from being executed multiple times by comparing the value of the virtual card's client device not present top-up counter RCounter. That is, cach top-up command can only be executed once. When performing the client device not present top-up, the client phone can write the client device not present top-up counter into the latest transaction record and store it in the memory module of the client phone. When the next transaction is performed, the POS terminal compares the RCounter in the transaction record sent by the client phone with the RCounter in the top-up command stored in the POS terminal to determine whether or not to execute the top-up command. If the former is greater than or equal to the latter, it indicates that the relevant top-up command has been executed and needs not to be executed.
Combining the above technologies, the present invention can quickly lay out a payment platform in a country where the communication network is not well developed:
The case of obtaining the transaction token may include the following: The new user obtains the transaction token while registering, the existing user obtains the transaction token while logging in, and the client phone checks the transaction record and updates the transaction token from time to time, etc.
The method for obtaining a transaction token in various cases is similar, and may include the following steps:
In step T1, the user enters a username and a password on the client phone.
In step T2, the client phone can randomly generate a challenge Nc and a session key, and encrypt the two using the public key of the payment server. The encrypted data is then sent over the Internet to the payment server. The transmission channel used to transmit the randomly generated challenge Nc and the session key may include: the communication link of WAP (Wireless Application Protocol), CDMA (Code Division Multiple Access), Wi-Fi, WIMAX (Worldwide Interoperability for Microwave Access, WCDMA (Wide Band Code Division Multiple Access), TD-CDMA (Time Division-Synchronous Code Division Multiple Access), CDMA2000, etc.
In step T3, the payment server decrypts the message sent by the client phone with its own private key, and then signs the verifier Ne sent by the client phone with its own private key, and adds the signed challenge Nc. to the challenge Ns randomly generated by the payment server. Finally, the processed challenge Ns is encrypted by the session key sent by the client phone, and the encrypted challenge Ns is sent to the client phone.
In step T4, after receiving the reply sent by the payment server, the client phone decrypts the reply with the session key and generates a login request. The login request may include: a challenge Ns, a user name, a hashed password processed by a hash function Hash (Password), a card number Card ID, a device number Device ID, and a transaction record list Transaction List. The client phone then encrypts the login request with the session key and sends the encrypted login request to the payment server. Among them, if is a case of new user registration or a logging of existing user, a card number is randomly generated, and the card number used in the transaction is added in the login request. If is a case of the transaction record being checked and the transaction token being updated, the existing card number Card ID is added to the login request. If it is a case of the transaction record being checked and the transaction token being updated, the transaction record list TransactionList records all transactions that have been made since the transaction token was last received. If a new user registers or an existing user login, the transaction record list TransactionList is empty.
In step T5, after receiving the login request, the payment server first decrypts the request with the session key, and then checks the related user name and the hashed password Hash (Password). If it is determined that the current login request is a command to check the transaction record and update the transaction token, according to the card number Card ID, the server may extract the transaction record list previously received from the POS terminal. The server then compares the transaction record list TransactionList received from the client phone with the extracted transaction record list. If the comparison result is correct, the following message is generated: Ns+1, a transaction token Token, and the signature of the token SIGNpos(Token). Among them, Ns+1 is the value of the challenge Ns plus one, which can prevent replay attacks. The transaction token includes a device number Device ID, a card number Card ID, a virtual card balance Bal, a transaction counter TCounter, a client device not present top-up counter RCounter, and a expiry date of the transaction token Token Validity. The transaction token is recorded in the memory module of the client phone. The SIGNpos(Token) can be obtained by signing the Token with the private key stored in the secure clement 101 of the POS terminal. The message that aggregates Ns+1, the transaction token Token and the SIGNpos(Token) is encrypted with the session key and sent to the client phone. In the case of a new user registration, the value of the virtual card balance Bal, the transaction counter TCounter, and the client device not present top-up counter RCounter in the transaction token Token are all 0. If the old user logs in or checks the transaction record and updates the transaction token, the virtual card balance Bal, the cumulative count of transactions TCounter, and the client device not present top-up counter RCounter are the existing values of the virtual card. If the old user logs in, the card number is randomly generated by the client phone, and the card number of the original old virtual card is added to the blacklist.
In the case of checking the transaction record and updating the transaction token, after receiving the transaction record list TransactionList, the payment server can check whether each transaction in the transaction record list TransactionList has been sent by the POS terminal. If yes, the comparison is made. If the POS terminal fails to send several transaction records due to offline operation, the payment server may first store the transaction record list TransactionList sent by the client phone, and when transaction records mentioned above is sent from the POS terminal, the comparison can then be made. By confirming that there is no conflict between the transaction records sent by the POS terminal and the transaction records sent by the client phone, a new transaction token can be generated for step T6.
In the case where the new user is registered and the existing user is logged in (ie, the old user is logged in), the transaction record is no need to be checked in step T5, and step T6 is directly performed.
In step T6, the client phone decrypts the message fed back by the payment server by using the session key. The relevant transaction token Token and its signature SIGNpos(Token) are stored to the memory module 203.
The information transfer process of the above communication session can be expressed in the following ways:
In the case of consumer transactions, the transactions between a client phone and a POS terminal include the following steps:
If the client phone just downloads a new transaction token from the payment server before the transaction, the token can reflect the latest transaction data. Thus, the last transaction record Transaction n and the signature SIGNpos(Transaction n) of this transaction record are empty.
After the two-dimensional code is displayed on the client phone, the client phone waits for Bluetooth answer. And, every few seconds or a preset time, the client phone can update the timestamp in the above two-dimensional code, and encrypt the foregoing information in the same manner, and then display the content in the form of a two-dimensional code. In this way, the POS terminal prevents replay attacks by checking the timestamp.
The above communication session can be expressed in the following ways:
In some embodiments, the above two-dimensional code may further include a reply message address. The value of this address can be randomly generated. The client phone while showing the two-dimensional code also scans the message packet with the above address in the Bluetooth broadcast message. In this way, the client phone can select a message related to the transaction from a plurality of Bluetooth broadcast messages.
In some embodiments, when the POS terminal feedbacks a message to the client phone, the POS terminal can transmit the message by using the Bluetooth broadcast message packet carrying the address, without making a low-power Bluetooth connection with the client phone. This saves the time of Bluetooth connection and speeds up the transaction.
In some embodiments, if the length of the feedback message exceeds the length limit of a Bluetooth broadcast message packet, the POS terminal divides the feedback message into multiple segments, and adds a sequence number to the message packet to identify the segment of the message packet in the feedback message. The transmission is repeated in turn by multiple Bluetooth broadcast packets until it is scanned from the two-dimensional code scanner to the transaction confirmation message displayed on the client phone. When the client phone scans the Bluetooth broadcast message, the above-mentioned feedback message is reorganized through the above sequence number. This design can efficiently transmit messages close to 140 bytes in about 1.5 seconds. Also, it can avoid transaction failures and delays caused by Bluetooth connection failures. The embodiment of the invention significantly improves the transaction speed and stability of the Android mobile phone as a client mobile phone.
The top-up method provided by the invention aims to realize the function of the client device not present top-up, and can complete the top-up in the case that the client phone has no network, even in the case that the top-up merchant has no terminal.
When the cardholder performs the client device not present top-up, the cardholder can hand over the cash and card number to the top-up merchant. Merchants use their own computers or mobile phones to log in to virtual card top-up platform of the merchant and enter the top-up amount and card number to top-up. The relevant operation after inputting the top-up amount and the card number can be implemented by the following session onc.
After the payment server handles the data, the POS terminal downloads the latest top-up command list from the payment server, and stores the top-up command list in the top-up command list memory module 105. The steps are implemented by the following session two.
When the client phone performs a purchase transaction at any POS terminal, the POS terminal searches for the top-up command from the top-up command list memory module 105. If a top-up command corresponding to virtual card number of the client phone is found, the top-up is simultaneously performed in the same communication session with the consumer transaction. The steps are implemented by the following three sessions.
In the offline case, if the transaction record of the hands-free offline top-up is not sent to the payment server in time, it may cause a top-up command to be executed more than once. In order to avoid this situation, the POS terminal can prevent the same top-up command from being executed more than once by comparing client not present top-up counter without machine RCounter of the virtual card in the client phone. When performing the hands-free offline top-up, the POS terminal writes the offline top-up count without machine into the latest transaction record and stores it in the memory module of the client phone. When the transaction is to be performed next time, the POS terminal compares the RCounter in the transaction record sent by the client phone with the RCounter of the corresponding top-up command stored in the POS terminal. If the former is greater than or equal to the latter, it indicates that the top-up command has been executed and the command will not be executed repeatedly. In the offline case, the POS terminal can prevent the same top-up command from being executed more than once by comparing the value of the RCounter.
The communication of the hands-free offline top-up includes the following steps:
If the client phone just downloads a new transaction token from the payment server before the transaction, the token can reflect the latest transaction data. Thus, the last transaction record Transaction n and the signature SIGNpos(Transaction n) of this transaction record are empty. And, the client phone updates the timestamp of the above two-dimensional code every few seconds or a preset time, and encrypts the serialized information in the same manner, and then displays the information in the form of a two-dimensional code. In this way, the POS terminal can prevent replay attacks by checking the timestamp.
The transmission channel in the session 1 is the Internet, and the merchant generally uses a computer or a mobile phone to log in to the merchant virtual card top-up module 301 in the payment server as a merchant. The merchant collects cash from the virtual card holder and then sends the merchant top-up command to the merchant virtual card top-up platform, including a card number and an amount. The virtual card corresponding to the card number can be displayed on the client phone in the form of a two-dimensional code, so that the merchant can scan by using the two-dimensional code scanner of the computer or the mobile phone. Also, the card number can be manually input.
After receiving the merchant top-up command, the merchant virtual card top-up module 301 first confirms whether the information in the instruction is correct. If correct, a system top-up command is generated and recorded in the memory module 302. The above system top-up commands include: a card number (Card ID), a top-up amount (TopUpAmount) and an offline top-up count without machine of the virtual card (RCounter). The value of RCounter is the maximum value of the offline top-up count without machine of the card (RCounter) plus one.
The payment server places the top-up command that has not been executed into the memory module 302. The POS terminal periodically downloads the updated top-up list from the payment server.
As described in session 2, the POS terminal periodically sends a download request for a top-up command list (GetTopUpUpdate) to the payment server via the Internet, and the payment server returns the top-up command list (TopupCmdList) to the POS terminal after receiving the request. After receiving the above top-up command list, the POS terminal stores it in the memory module 105 for storing top-up commands of the POS terminal.
As mentioned in Session 3: When the cardholder makes the next purchase through the client phone, it can simultaneously top-up and consume in the same transaction, saving the time and effort.
Referring to
In some embodiments, the transaction record includes a virtual card balance and a transaction counter. The new transaction record is generated by the POS terminal according to the virtual card balance and the cumulative count of transactions in the last transaction record and the transaction amount, after verifying that the transaction token is valid.
In some embodiments, the transaction token further includes a virtual card balance and a transaction counter. The method further comprises: clearing the transaction record stored in the client device while receiving the transaction token. In case that the last transaction record is empty, the new transaction record is generated by the POS terminal according to the virtual card balance and the cumulative count of transactions included in the transaction token and the transaction amount, after verifying that the transaction token is valid
In some embodiments, the method further includes obtaining a new transaction token as follows:
Transmitting a transaction record list to the payment server; wherein the transaction record list includes all transaction records performed by the client device and the POS terminal after receiving the transaction token; the transaction list is configured to compare with all of the transaction records uploaded by the POS terminal to the payment server. Receiving a new transaction token sent by the payment server. The new transaction token is generated in a case where the comparison does not conflict, and the new transaction token includes a new expiry date, the new expiry date is later than the current time.
In some embodiments, the transaction token includes a virtual card ID of the client device, and the transaction record includes an client device not present top-up counter, the method further comprising:
First, receiving a top-up transaction record sent by the POS terminal before receiving the top-up transaction record sent by the POS terminal; wherein the top-up transaction record is generated by the POS terminal according to the top-up amount of the top-up command and the last transaction record after the POS terminal verifies that the transaction token is valid and the client device not present top-up counter of the top-up command corresponding to the virtual card found by the POS terminal is greater than the client device not present top-up counter recorded in the last transaction record; the top-up command is downloaded by the POS terminal from the payment server, and is generated while a card holder of the client device logs in the payment server through the merchant device for top-up; the value of the client device not present top-up counter of the top-up transaction record is the value of the client device not present top-up counter of the top-up command.
Second, storing the top-up transaction record and transmitting a successful top-up result to the POS terminal to receive the new transaction record; wherein the last transaction record recorded by the POS terminal is updated to the top-up transaction record.
In some embodiments, the transaction token includes a comprehensive credit value; the comprehensive credit value is configured to determine whether to generate a new transaction record by the POS terminal when the transaction amount is greater than a set transaction amount threshold.
In some embodiments, the transaction token further includes a generation time. The generation time is configured to determine whether to generate the new transaction record by the POS terminal when the transaction amount is greater than a set transaction amount threshold wherein the generation time is used to generate, according to the transaction token, when the transaction amount is greater than a set transaction amount threshold Time to decide whether to generate the new transaction record.
In some embodiments, the two-dimensional code further includes a reply message address, and the receiving a new transaction record via Bluetooth sent by the POS terminal comprises:
In some embodiments, the obtaining a new transaction record sent by the POS terminal from the message packet comprises:
Reassembling the obtained message packet according to the sequence number of the obtained message packet;
Obtaining a new transaction record sent by the POS terminal, from the reassembled message packet.
Referring to
In some embodiments, the transaction record includes a virtual card balance and a transaction counter, and the generating a new transaction record according to the transaction amount input by a merchant to the POS terminal and the last transaction record. It comprises the following steps:
Subtracting the transaction amount from the virtual card balance in the last transaction record to obtain a virtual card balance of the new transaction record.
The transaction counter in the last transaction record is incremented by one to obtain the cumulative count of transactions of the new transaction record.
In some embodiments, the transaction token further includes a virtual card balance and a cumulative count of transactions, the generating a new transaction record according to the transaction amount input by a merchant to the POS terminal and the last transaction record comprises:
In some embodiments, the method comprises:
Uploading the new transaction record to the payment server for storing a transaction record set corresponding to the client device; the transaction record set includes transaction records performed by the client device and the POS terminal uploaded by the POS terminal after the payment server sends the transaction token to the client device; The purpose of the transaction record set is to facilitate the payment server to compare them with the transaction record sent from the POS terminal, and generating, by the payment server, a new transaction token for transmission to the client device if the there is no conflict found during the comparison; the new transaction token includes a new expiry date , the new expiry date is later than the current time.
In some embodiments, the method further comprises: downloading a top-up command from the payment server; wherein the top-up command is generated while a card holder of the client device logs in the payment server for top-up; and the top-up command includes a top-up amount, a virtual card ID and an client device not present top-up counter.
In some embodiments, the transaction token includes a virtual card ID of the client device, and the transaction record includes a client device not present top-up counter of the virtual card. The method may further include:
First, after the POS terminal verifies that the transaction token is valid, searching for a top-up command of the virtual card according to the virtual card ID.
Then, if the client device not present top-up counter of the top-up command is greater than the client device not present top-up counter recorded in the last transaction record, generating a top-up transaction record according to the top-up amount of the top-up command and the last transaction record obtained from the client device; wherein, the value of the client device not present top-up counter of the top-up transaction record is the value of the offline top-up count without machine of the top-up command.
Furthermore, updating the last transaction record to the top-up transaction record.
In some embodiments, the transaction record includes a virtual card balance and a transaction counter. And the generated a top-up transaction record according to the top-up amount of the top-up command and the last transaction record obtained from the client device comprises:
Incrementing the transaction counter in the last transaction record by one to obtain a cumulative count of transactions of the new transaction record.
In some embodiments, the transaction token includes a comprehensive credit value; the method further comprises:
If the transaction amount is greater than a preset transaction amount threshold, determining whether to generate a new transaction record according to the comprehensive credit value.
In some embodiments, the transaction token further includes a generation time; the method further comprises:
If the transaction amount is greater than the preset transaction amount threshold, determining whether to generate the new transaction record according to the generation time of the transaction token.
In some embodiments, the two-dimensional code further includes a reply message address, and the sending the new transaction record to the client device via Bluetooth comprises:
In some embodiments, the sending the message packet by a Bluetooth broadcast message comprises:
Referring to
Referring to
In some embodiments, the POS terminal further includes:
The payment server communication module, further configured to download a top-up command from the payment server, wherein the top-up command is generated while a card holder of the client device logs in the payment server for top-up, and the top-up command includes a top-up amount. a virtual card ID and an client device not present top-up counter; and a top-up command memory module, configured to store the top-up command.
This application is a continuation of U.S. application Ser. No. 16/681,365, filed Nov. 12, 2019, titled “Method, Client Device and POS Terminal for Offline Transaction”, which claims priority to Chinese Patent Application No. 201910340975.1 filed Apr. 25, 2019, titled “Method, Client Device and POS Terminal for Offline Transaction”. The content of the aforementioned application, including any intervening amendments thereto, are incorporated herein by reference.
Number | Date | Country | |
---|---|---|---|
Parent | 16681365 | Nov 2019 | US |
Child | 18665181 | US |