Method, server, and readable storage medium for processing payment in offline scenario
An implementation of the present specification discloses a method for processing payment in an offline scenario. A collection terminal, when in an offline state, scans an offline code generated by a user terminal in an offline state to obtain offline code information, obtains a payment amount, and saves the offline code information and the payment amount, and if in an online state, uploads the offline code information and the payment amount to a server, so that after receiving the offline code and the payment amount, the server pays a deduction amount from a corresponding payment account based on the offline code information and the payment amount, and thus puts the deduction amount into a payment account corresponding to the collection terminal. As such, the payment function can still be achieved when the user terminal and the collection terminal are in an offline state.
1. A method for processing electronic payment in an offline scenario, the method comprising:
at a payment collection terminal, scanning, by the payment collection terminal that is in a first offline state, an offline code generated by a user terminal that is in a second offline state, to obtain offline code information;
providing, by the payment collection terminal, a payment amount;
saving, by the payment collection terminal that remains in the first offline state, the offline code information and the payment amount in a form that associates the offline code and the payment amount;
after the offline code information and the payment amount are saved, detecting, by the payment collection terminal, the payment collection terminal transitioning from the first offline state to an online state; and
responsive to detecting the payment collection terminal transitioning from the first offline state to the online state:
uploading the offline code information and the payment amount to a server, wherein responsive to the uploading of the offline code information and the payment amount the server initiates monitoring in real time whether the user terminal transitions to an online state,
wherein responsive to detecting the user terminal transitions to an online state, determining by the server a payment deduction channel from the user terminal, and
obtaining a deduction amount provided by the server for payment based on the offline code information and the payment amount.
2. The method according to claim 1 , wherein the saving the offline code information and the payment amount includes:
encrypting the offline code information using a private key maintained by the payment collection terminal;
encrypting the payment amount using the private key maintained by the payment collection terminal; and
assembling the encrypted offline code information and the encrypted payment amount into collection information, and saving the collection information.
3. The method according to claim 2 , wherein the uploading the offline code information and the payment amount to the server includes:
encrypting the collection information using a private key maintained by the payment collection terminal; and
uploading the encrypted collection information to the server.
4. A payment collection terminal, comprising:
an offline code generation unit, configured to scan, when the payment collection terminal is in a first offline state, an offline code generated by a user terminal that is in a second offline state to obtain offline code information;
a payment amount acquisition unit, configured to provide a payment amount;
an information storage unit, configured to save the offline code information and the payment amount in a form that associates the offline code and the payment amount, when the payment collection terminal remains in the first offline state; and
an information uploading unit, configured to:
after the offline code information and the payment amount are saved, detect the payment collection terminal transitioning from the first offline slate to an online state, and
responsive to detecting the payment collection terminal transitioning from the first offline state to the online state:
upload the offline code information and the payment amount to a server, wherein responsive to the uploading of the offline code information and the payment amount the server initiates monitoring in real time whether the user terminal transitions to an online state,
wherein responsive to detecting the user terminal transitions to an online state, determining by the server a payment deduction channel from the user terminal, and
obtain a deduction amount provided by the server for payment based on the offline code information and the payment amount.
5. The payment collection terminal according to claim 4 , wherein the information storage unit is further configured to:
encrypt the offline code information using a private key maintained by the payment collection terminal;
encrypt the payment amount using the private key maintained by the payment collection terminal; and
assemble the encrypted offline code information and the encrypted payment amount into collection information, and save the collection information.
6. The payment collection terminal according to claim 5 , wherein the information uploading unit is further configured to upload the collection information to the server.
7. A non-transitory computer-readable medium storing contents that, when executed by one or more processors, cause the one or more processors to perform actions comprising:
at a payment collection terminal that is in a first offline state, scanning an offline code generated by a user terminal that is in a second offline state, to obtain offline code information;
producing, by the payment collection terminal, a payment amount;
saving, by the payment collection terminal that remains in the first offline state, the offline code information and the payment amount in a form that associates the offline code and the payment amount;
after the offline code information and the payment amount are saved, detecting, by the payment collection terminal, the payment collection terminal transitioning from the first offline state to an online state; and
responsive to detecting the payment collection terminal transitioning from the first offline state to the online state;
uploading the offline code information and the payment amount to a server, wherein responsive to the uploading of the offline code information and the payment amount the server initiates monitoring in real time whether the user terminal transitions to an online state,
wherein responsive to detecting the user terminal transitions to an online state, determining by the server a payment deduction channel from the user terminal, and
obtaining a deduction amount provided by the server for payment based on the offline code information and the payment amount.
8. The computer-readable medium according to claim 7 , wherein the saving the offline code information and the payment amount includes:
assembling the offline code information and the payment amount into collection information, and saving the collection information.
9. The computer-readable medium according to claim 8 , wherein the uploading the offline code information and the payment amount to the server includes:
encrypting the collection information using a private key maintained by the payment collection terminal; and
uploading the encrypted collection information to the server.