CN106779635B - Smart card and method for sharing balance of multiple accounts in smart card - Google Patents
Smart card and method for sharing balance of multiple accounts in smart card Download PDFInfo
- Publication number
- CN106779635B CN106779635B CN201611042232.9A CN201611042232A CN106779635B CN 106779635 B CN106779635 B CN 106779635B CN 201611042232 A CN201611042232 A CN 201611042232A CN 106779635 B CN106779635 B CN 106779635B
- Authority
- CN
- China
- Prior art keywords
- balance
- instruction
- transaction
- module
- application
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Active
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q20/00—Payment architectures, schemes or protocols
- G06Q20/04—Payment circuits
- G06Q20/06—Private payment circuits, e.g. involving electronic currency used among participants of a common payment scheme
- G06Q20/065—Private payment circuits, e.g. involving electronic currency used among participants of a common payment scheme using e-cash
- G06Q20/0655—Private payment circuits, e.g. involving electronic currency used among participants of a common payment scheme using e-cash e-cash managed centrally
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q20/00—Payment architectures, schemes or protocols
- G06Q20/08—Payment architectures
- G06Q20/10—Payment architectures specially adapted for electronic funds transfer [EFT] systems; specially adapted for home banking systems
- G06Q20/105—Payment architectures specially adapted for electronic funds transfer [EFT] systems; specially adapted for home banking systems involving programming of a portable memory device, e.g. IC cards, "electronic purses"
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q20/00—Payment architectures, schemes or protocols
- G06Q20/30—Payment architectures, schemes or protocols characterised by the use of specific devices or networks
- G06Q20/34—Payment architectures, schemes or protocols characterised by the use of specific devices or networks using cards, e.g. integrated circuit [IC] cards or magnetic cards
- G06Q20/357—Cards having a plurality of specified features
- G06Q20/3572—Multiple accounts on card
Landscapes
- Business, Economics & Management (AREA)
- Accounting & Taxation (AREA)
- Engineering & Computer Science (AREA)
- Physics & Mathematics (AREA)
- Strategic Management (AREA)
- General Business, Economics & Management (AREA)
- General Physics & Mathematics (AREA)
- Theoretical Computer Science (AREA)
- Finance (AREA)
- Computer Networks & Wireless Communication (AREA)
- Microelectronics & Electronic Packaging (AREA)
- Development Economics (AREA)
- Economics (AREA)
- Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)
Abstract
The invention discloses a smart card and a method for sharing balance of multiple accounts in the smart card, wherein the method comprises the following steps: the intelligent card receives an instruction, after receiving an application selection instruction from a financial terminal, whether an M1 transaction state flag is set is detected, if not, the relationship among the balance of the M1, the balance of the electronic wallet and the balance of the electronic cash is judged, if the balance of the M1 is minimum, the balance of the electronic wallet and the balance of the electronic cash are respectively updated to the balance of the M1, the application is selected, an application selection success response is returned, and the instruction continues to be received; after receiving an application transaction instruction from the financial terminal, calculating the balance of the current account according to the transaction amount in the application transaction instruction; the current account balance is the current electronic wallet balance or the current electronic cash balance; setting an M1 transaction state flag, starting a transaction, respectively updating the balance of the M1, the balance of the electronic wallet and the balance of the electronic cash to the current account balance, closing the transaction, resetting the M1 transaction state flag, and returning a transaction success response.
Description
Technical Field
The invention relates to the field of smart cards, in particular to a smart card and a method for sharing balance of multiple accounts in the smart card.
Background
In the prior art, various smart cards exist, such as an encrypted memory card (M1 card), an industry application card supporting electronic wallet application, a financial card supporting electronic cash application, and the like, wherein an M1 account is stored in the encrypted memory card, an electronic wallet account is stored in the industry application card, and an electronic cash account is stored in the financial card, and because account balances in various smart cards are independent, each smart card can only be used in a terminal supporting respective application, and cannot be compatible with other terminals. Therefore, the smart card industry has the problems of high maintenance cost, serious resource waste and the like. Therefore, there is a need for a smart card that is capable of sharing multiple account balances.
Disclosure of Invention
The invention provides a smart card and a method for sharing balance of multiple accounts in the smart card, which solve the technical problems.
The invention provides a method for sharing balances of multiple accounts in a smart card, which comprises the following steps:
step s 1: the smart card receives the instruction, and after the smart card receives the application selection instruction from the financial terminal, the step s2 is executed; when the smart card receives the application transaction instruction from the financial terminal, executing step s 6;
step s 2: the smart card detects whether the self M1 transaction status flag is set, if so, the step s5 is executed; otherwise, go to step s 3;
step s 3: the smart card judges the relationship among the balance of the smart card M1, the balance of the electronic wallet and the balance of the electronic cash, and if the balance of the smart card M1 is minimum, the step s4 is executed; if the M1 balance, the electronic wallet balance and the electronic cash balance are equal, executing step s 5; if the balance of the M1 is greater than the balance of the electronic wallet or the balance of the electronic cash, reporting an error to the financial terminal, and ending;
step s 4: the smart card updating the electronic wallet balance to the M1 balance; updating the electronic cash balance to the M1 balance;
step s 5: the intelligent card selects the application according to the application selection instruction, returns an application selection success response to the financial terminal and returns to the step s 1;
step s 6: the intelligent card calculates the balance of the current account according to the transaction amount in the application transaction instruction; the current account balance is the current electronic wallet balance or the current electronic cash balance;
step s 7: the smart card locates the M1 transaction status flag to start the transaction;
step s 8: the smart card respectively updates the M1 balance, the electronic wallet balance and the electronic cash balance to the current account balance;
step s 9: the smart card closes the transaction; and after closing the transaction, resetting the M1 transaction status flag, returning a successful transaction response to the financial terminal, and ending.
The present invention also provides a smart card comprising: the system comprises a first receiving module, a second receiving module, a first detecting module, a first judging module, a first error reporting module, a first updating module, a first application module, a first returning module, a first calculating module, a first transaction module, a first setting module, a second updating module and a second returning module;
the first receiving module is used for receiving an application selection instruction from the financial terminal;
the second receiving module is used for receiving an application transaction instruction from the financial terminal;
the first detection module is configured to detect whether an M1 transaction status flag of the first reception module is set after the first reception module receives the application selection instruction;
the first judging module is used for judging the relationship among the balance of the M1, the balance of the electronic purse and the balance of the electronic cash when the first detecting module detects that the balance is negative;
the first updating module is configured to update the balance of the electronic wallet to the M1 balance when the first determining module determines that the balance of the M1 is minimum; updating the electronic cash balance to the M1 balance;
the first application module is configured to, when the first determining module determines that the M1 balance, the electronic wallet balance, and the electronic cash balance are equal to each other, and the first updating module updates the electronic wallet balance and the electronic cash balance, select an application according to the application selection instruction;
the first error reporting module is configured to report an error to the financial terminal when the first determining module determines that the balance of the M1 is greater than the balance of the electronic wallet or the balance of the electronic cash;
the first returning module is used for returning an application selection success response to the financial terminal after the first application module selects the application according to the application selection instruction;
the first calculation module is used for calculating the balance of the current account according to the transaction amount in the application transaction instruction; the current account balance is the current electronic wallet balance or the current electronic cash balance;
the first setting module is used for setting the M1 transaction status flag after the first calculation module calculates the current account balance; resetting the M1 transaction status flag when the first transaction module closes a transaction;
the first transaction module is used for starting a transaction after the first calculation module calculates the balance of the current account; when the second updating module respectively updates the M1 balance, the electronic wallet balance and the electronic cash balance into the current account balance, closing the transaction;
the second updating module is configured to update the M1 balance, the electronic wallet balance, and the electronic cash balance to the current account balance respectively after the first transaction module starts a transaction;
the second returning module is configured to return a transaction success response to the financial terminal after the second updating module updates the M1 balance, the electronic wallet balance, and the electronic cash balance to the current account balance, respectively.
The invention has the beneficial effects that: the invention provides a smart card and a method for sharing balance of multiple accounts in the smart card, wherein M1 balance, electronic purse balance and electronic cash balance in the smart card are shared, so that the smart card can be used on a terminal supporting electronic cash application, a terminal supporting an encrypted memory card and a terminal supporting electronic purse application.
Drawings
Fig. 1 is a flowchart of a method for sharing balances of multiple accounts in a smart card according to embodiment 1 of the present invention;
fig. 2 is a flowchart of a method for sharing balances of multiple accounts in a smart card according to embodiment 2 of the present invention;
3-5 are flowcharts of a method for sharing balances of multiple accounts in a smart card according to embodiment 3 of the present invention;
fig. 6 is a block diagram of a smart card according to embodiment 4 of the present invention.
Detailed description of the invention
The technical solutions in the embodiments of the present invention will be clearly and completely described below with reference to the drawings in the embodiments of the present invention, and it is obvious that the described embodiments are only a part of the embodiments of the present invention, and not all of the embodiments. All other embodiments, which can be derived by a person skilled in the art from the embodiments given herein without making any creative effort, shall fall within the protection scope of the present invention.
Example 1
The embodiment provides a method for sharing a balance of multiple accounts in a smart card, as shown in fig. 1, including:
step s 1: the smart card receives the instruction, and after the smart card receives the application selection instruction from the financial terminal, the step s2 is executed; when the smart card receives the application transaction instruction from the financial terminal, executing step s 6;
in this embodiment, step s1 may further include: after receiving the M1 consumption command from the M1 terminal, executing the step r 1;
step r 1: the smart card detects whether the self M1 transaction state flag is set, and if so, an error is reported to the M1 terminal; otherwise, go to step r 2;
step r 2: the smart card calculates the current M1 balance, updates the M1 balance to the current M1 balance, and returns the consumption success information to the M1 terminal.
Wherein, calculating the current M1 balance, updating the M1 balance to the current M1 balance, specifically: the smart card acquires the M1 balance from the M1 storage area, acquires the M1 transaction amount from the M1 consumption instruction, calculates the difference between the M1 balance and the M1 transaction amount, takes the difference between the M1 balance and the M1 transaction amount as the current M1 balance, and writes the current M1 balance into the M1 storage area as the M1 balance.
Step s 2: the smart card detects whether the self M1 transaction state flag is set, if so, the step s5 is executed; otherwise, go to step s 3;
step s 3: the smart card judges the relationship among the balance of the smart card M1, the balance of the electronic wallet and the balance of the electronic cash, and if the balance of the smart card M1 is minimum, the step s4 is executed; if the balance of the M1, the balance of the electronic wallet and the balance of the electronic cash are equal, executing step s 5; if the balance of the M1 is larger than the balance of the electronic wallet or the balance of the electronic cash, reporting an error to the financial terminal, and ending;
specifically, the smart card obtains an M1 balance from the M1 storage area; obtaining the balance of the electronic purse from the first nonvolatile storage area; obtaining an electronic cash balance from the second nonvolatile storage area; judging whether the balance of the M1 is larger than the balance of the electronic wallet or the balance of the electronic cash, if so, reporting an error to the financial terminal, and ending; otherwise: if the M1 balance is less than the electronic wallet balance and the M1 balance is less than the electronic cash balance, then go to step s 4; if the M1 balance equals the electronic wallet balance and the M1 balance equals the electronic cash balance, step s5 is performed.
The obtaining of the M1 balance from the M1 storage area specifically includes:
step s 31: the smart card acquires an address of the M1 wallet copy in the storage area of the M1, and acquires an M1 wallet copy according to the address of the M1 wallet copy;
step s 32: the smart card determines whether the M1 wallet copy is legitimate, and if so, performs step s 33; otherwise, go to step t 31;
step s 33: the smart card obtains the M1 balance from the M1 wallet copy;
step t 31: the smart card obtains the M1 wallet original address in the M1 storage area; obtaining an M1 wallet master according to the M1 wallet master address;
step t 32: the smart card judges whether the M1 wallet certificate is legal, if so, the step t33 is executed; otherwise, go to step s 5;
step t 33: the smart card obtains the M1 balance from the M1 wallet certificate.
When the M1 wallet essence is judged to be legal in step t32, before judging the relationship among the M1 balance, the electronic wallet balance and the electronic cash balance, the method may further include: the smart card writes the M1 wallet master as a copy of the M1 wallet to the M1 wallet copy address.
Step s 4: the intelligent card updates the balance of the electronic wallet to be M1 balance; updating the electronic cash balance to an M1 balance;
specifically, the smart card writes the M1 balance as the electronic wallet balance into the first nonvolatile storage area; the M1 balance is written as an electronic cash balance into the second non-volatile storage area.
Step s 5: the intelligent card selects the application according to the application selection instruction, returns an application selection success response to the financial terminal, and returns to the step s 1;
step s 6: the intelligent card calculates the balance of the current account according to the transaction amount in the application transaction instruction; the current account balance is the current electronic wallet balance or the current electronic cash balance;
step s 7: the smart card sets an M1 transaction state flag to start the transaction;
step s 8: respectively updating the M1 balance, the electronic purse balance and the electronic cash balance into the current account balance;
specifically, when the current account balance is the current electronic wallet balance, the smart card writes the current electronic wallet balance as the M1 balance into the M1 storage area; writing the current balance of the electronic wallet into a first nonvolatile storage area as the balance of the electronic wallet; writing the current electronic wallet balance as an electronic cash balance into a second non-volatile storage area;
when the current account balance is the current electronic cash balance, the intelligent card writes the current electronic cash balance into the M1 storage area as the M1 balance; writing the current electronic cash balance as the electronic wallet balance into a first nonvolatile storage area; the current electronic cash balance is written as an electronic cash balance into the second nonvolatile storage area.
Preferably, the first nonvolatile storage area is a Flash storage area of the electronic wallet application; the second nonvolatile storage area is a Flash storage area of the electronic cash application.
Step s 9: the smart card closes the transaction; and after closing the transaction, resetting the M1 transaction status flag, returning a successful transaction response to the financial terminal, and ending.
In this embodiment, before the step s6, the method may further include: judging whether the transaction amount in the application transaction instruction is legal, if so, executing a step s 6; otherwise, reporting an error to the financial terminal, and ending.
Further, applying the transaction instructions comprises: an electronic wallet consumption instruction or an electronic wallet loading instruction or an electronic cash consumption instruction or an electronic cash loading instruction; if the smart card supports the overdraft function, then:
when the application transaction instruction is an electronic wallet consumption instruction, judging whether the transaction amount in the application transaction instruction is legal specifically as follows: the intelligent card judges whether the transaction amount is not larger than the result of adding the overdraft limit to the balance of the electronic wallet and then subtracting the overdraft amount, if so, the transaction amount is judged to be legal; otherwise, judging that the transaction amount is illegal;
when the application transaction instruction is an electronic wallet earmark instruction, judging whether the transaction amount in the application transaction instruction is legal or not specifically as follows: the intelligent card judges whether the transaction amount is not larger than the result of subtracting the balance of the electronic wallet from the upper limit of the balance, adding the overdrawn amount and subtracting the offline pre-authorized total amount, and if so, judges that the transaction amount is legal; otherwise, judging that the transaction amount is illegal;
when the application transaction instruction is an electronic cash consumption instruction, judging whether the transaction amount in the application transaction instruction is legal specifically as follows: the intelligent card judges whether the transaction amount is not larger than the result of adding the overdraft limit to the electronic cash balance and then subtracting the overdraft amount, if so, the transaction amount is judged to be legal; otherwise, judging that the transaction amount is illegal;
when the application transaction instruction is an electronic cash load instruction, judging whether the transaction amount in the application transaction instruction is legal specifically as follows: the intelligent card judges whether the transaction amount is not larger than the result of adding the upper limit of the balance amount and subtracting the offline pre-authorization total amount from the overdrawn amount, and if so, the transaction amount is judged to be legal; otherwise, the transaction amount is judged to be illegal.
Further, applying the transaction instructions comprises: an electronic wallet consumption instruction or an electronic wallet loading instruction or an electronic cash consumption instruction or an electronic cash loading instruction; if the card does not support the overdraft function:
when the application transaction instruction is an electronic wallet consumption instruction, judging whether the transaction amount in the application transaction instruction is legal specifically as follows: the intelligent card judges whether the transaction amount is not greater than the balance of the electronic wallet, and if so, judges that the transaction amount is legal; otherwise, judging that the transaction amount is illegal;
when the application transaction instruction is an electronic wallet earmark instruction, judging whether the transaction amount in the application transaction instruction is legal or not specifically as follows: the intelligent card judges whether the transaction amount is not larger than the result of subtracting the electronic wallet balance from the balance upper limit and subtracting the offline preauthorization total amount, if so, the transaction amount is judged to be legal; otherwise, judging that the transaction amount is illegal;
when the application transaction instruction is an electronic cash consumption instruction, judging whether the transaction amount in the application transaction instruction is legal specifically as follows: the intelligent card judges whether the transaction amount is not greater than the balance of the electronic cash, and if so, the transaction amount is judged to be legal; otherwise, judging that the transaction amount is illegal;
when the application transaction instruction is an electronic cash load instruction, judging whether the transaction amount in the application transaction instruction is legal specifically as follows: the intelligent card judges whether the transaction amount is not larger than the result of subtracting the offline preauthorization total amount from the upper limit of the balance amount, if so, the transaction amount is judged to be legal; otherwise, the transaction amount is judged to be illegal.
In this embodiment, the application transaction instruction may specifically include: an electronic wallet consumption instruction or an electronic wallet earmark instruction;
when the application transaction instruction is an electronic wallet consumption instruction, calculating the current account balance according to the transaction amount in the application transaction instruction, specifically: calculating the difference value between the balance of the electronic wallet and the transaction amount, and taking the difference value as the balance of the current electronic wallet;
when the application transaction instruction is specifically an electronic wallet loading instruction, calculating the current account balance according to the transaction amount in the application transaction instruction, specifically: and calculating the sum of the balance of the electronic purse and the transaction amount, and taking the sum as the balance of the current electronic purse.
Further, the electronic wallet consuming instructions comprise: a consumption initialization instruction and a consumption instruction; or specifically comprises a composite consumption initialization instruction, a composite application data cache updating instruction and a composite application consumption instruction; the electronic wallet earmark instruction specifically comprises the following steps: a load initialization instruction and a first load instruction;
accordingly:
step s1 specifically includes: the smart card waits for receiving the instruction, and after receiving the application selection instruction from the financial terminal, the smart card executes step s 2; when the smart card receives the consumption initialization instruction, the smart card obtains the transaction amount from the consumption initialization instruction, judges whether the transaction amount is legal, if so, returns an initialization success response to the financial terminal, and returns to the step s 1; otherwise, reporting an error to the financial terminal, and returning to the step s 1; when the smart card receives the consumption instruction, step s6 is executed; when the smart card receives the composite consumption initialization instruction, the smart card obtains the transaction amount from the composite consumption initialization instruction, judges whether the transaction amount is legal, if so, returns an initialization success response to the financial terminal, and returns to the step s 1; otherwise, reporting an error to the financial terminal, and returning to the step s 1; when the smart card receives the composite application consumption instruction, executing step s 6; when the smart card receives the load initialization instruction, the smart card obtains the transaction amount from the load initialization instruction, judges whether the transaction amount is legal, if so, returns an initialization success response to the financial terminal, and returns to the step s 1; otherwise, reporting an error to the financial terminal, and returning to the step s 1; when the smart card receives the first load command, executing step s 6;
step s6 specifically includes: when the smart card receives the consumption instruction or the composite application consumption instruction, the smart card calculates the difference between the balance of the electronic wallet and the transaction amount, and takes the difference as the balance of the current electronic wallet, and executes step s 7; when the smart card receives the first credit rolling instruction, the smart card calculates the sum of the balance of the electronic wallet and the transaction amount, and takes the sum as the balance of the current electronic wallet, and executes the step s 7;
step s1 further includes: and when the smart card receives the instruction for updating the composite application data cache, the smart card updates the composite consumption record, returns an update success response to the financial terminal, and returns to the step s 1.
In this embodiment, the applying the transaction instruction may further specifically include: an electronic cash consumption instruction or an electronic cash loading instruction;
when the transaction command is an electronic cash consumption command, step s6 is specifically: the intelligent card calculates the difference between the balance of the electronic cash and the transaction amount, and takes the difference as the balance of the current electronic cash;
when the transaction command is an electronic cash load command, step s6 is specifically: the smart card takes the transaction amount as the current electronic cash balance.
Further, the electronic cash consumption instruction specifically includes: acquiring a processing option instruction and a reading record instruction; or specifically comprises the following steps: reading an extended application recording instruction, acquiring a processing option instruction, updating the extended application recording instruction and reading the recording instruction; the electronic cash loading instruction specifically comprises the following steps: acquiring a processing option instruction, a reading recording instruction, a first application ciphertext generation instruction, a second application ciphertext generation instruction and a second load instruction;
accordingly:
step s1 specifically includes: the smart card waits for receiving the instruction, and after receiving the application selection instruction from the financial terminal, the smart card executes step s 2; when the smart card receives the instruction for acquiring the processing option, the transaction type is judged according to the instruction for acquiring the processing option, when the transaction type is qPBOC transaction, the transaction type identifier is set as a first type identifier, the smart card acquires the transaction amount from the instruction for acquiring the processing option, whether the transaction amount is legal is judged, and if the transaction amount is legal, the step s6 is executed; otherwise, reporting an error to the financial terminal, and returning to the step s 1; when the transaction type is qPBOC expanded transaction, setting the transaction type identifier as a second type identifier, acquiring the transaction amount from the acquisition processing option instruction by the smart card, judging whether the transaction amount is legal, and if so, executing a step s 6; otherwise, reporting an error to the financial terminal, and returning to the step s 1; when the transaction type is a debit and credit transaction, setting the transaction type identifier as a third type identifier, returning an application initialization response to the financial terminal, and returning to the step s 1; when the smart card receives the second load instruction, the smart card obtains the transaction amount from the second load instruction, judges whether the transaction amount is legal, and if so, executes step s 6; otherwise, reporting an error to the financial terminal, and returning to the step s 1; when the smart card receives the record reading instruction, detecting the transaction type identifier, and executing step s7 when the transaction type identifier is the first type identifier or the second type identifier; when the transaction type identifier is the third type identifier, returning a read record response to the financial terminal, and returning to the step s 1;
step s6 specifically includes: if the transaction type is qPBOC transaction or qPBOC expansion transaction, when the smart card judges that the transaction amount is legal, the smart card calculates the difference between the electronic cash balance and the transaction amount, takes the difference as the current electronic cash balance, returns an application initialization response to the financial terminal, and returns to the step s 1; if the transaction type is a debit-credit transaction, and after the smart card judges that the transaction amount is legal, the smart card takes the transaction amount as the balance of the current electronic cash, and step s7 is executed;
step s1 further includes: when the smart card receives the instruction of reading the extended application record from the financial terminal, the smart card returns a response of reading the extended application record to the financial terminal, and returns to the step s 1; when the smart card receives the command of updating the extended application record, returning an update extended application record response to the financial terminal, and returning to the step s 1; after receiving the first generated application ciphertext instruction, the smart card returns a first generated application ciphertext response to the financial terminal, and returns to the step s 1; and when the smart card receives the second application ciphertext generating instruction, returning a second application ciphertext generating response to the financial terminal, and returning to the step s 1.
The embodiment provides a method for sharing the balance of multiple accounts in the smart card, and the M1 balance, the electronic purse balance and the electronic cash balance in the smart card are shared, so that the smart card can be used on a terminal supporting an electronic cash application, a terminal supporting an encrypted memory card and a terminal supporting an electronic purse application.
Example 2
The embodiment provides a method for sharing a balance of multiple accounts in a smart card, as shown in fig. 2, including:
step 101: the intelligent card waits for receiving an instruction from the terminal; when receiving the M1 consumption command from the M1 terminal, executing step 102; after receiving an application selection instruction from the financial terminal, executing step 104; when receiving the electronic wallet trade instruction from the financial terminal, executing step 108; when receiving the electronic cash transaction instruction from the financial terminal, execute step 115;
specifically, the smart card waits for receiving an instruction from the terminal; after receiving the M1 consumption command from the M1 terminal through the first communication channel, execute step 102; after receiving an application selection instruction from the financial terminal through the second communication channel, executing step 104; after receiving the e-wallet transaction command from the financial terminal through the second communication channel, performing step 108; after receiving the electronic cash transaction command from the financial terminal through the second communication channel, go to step 115;
in this embodiment, the electronic wallet transaction instruction includes: an electronic wallet consumption instruction or an electronic wallet earmark instruction; the electronic wallet consumption instruction specifically comprises the following steps: a consumption initialization instruction and a consumption instruction; or specifically comprises a composite consumption initialization instruction, a composite application data cache updating instruction and a composite application consumption instruction; the electronic wallet earmark instruction specifically comprises the following steps: the load memory comprises a load memory initialization command and a first load memory command.
The electronic cash transaction instructions include: an electronic cash consumption instruction or an electronic cash loading instruction; wherein, the electronic cash consumption instruction specifically comprises: acquiring a processing option instruction and a reading record instruction; or specifically comprises the following steps: acquiring a processing option instruction, updating an extended application recording instruction and reading a recording instruction; the electronic cash loading instruction specifically comprises the following steps: and acquiring a processing option instruction, a reading recording instruction, a first application ciphertext generation instruction, a second application ciphertext generation instruction and a second load instruction.
Step 102: the smart card detects whether the M1 transaction state flag is set, if so, an error is reported to the M1 terminal, and the step 101 is returned; otherwise, go to step 103;
step 103: the smart card calculates the current M1 balance and updates the M1 balance to the current M1 balance; returning the consumption success information to the M1 terminal, and returning to the step 101;
specifically, the smart card acquires the M1 balance from the M1 storage area, acquires the M1 transaction amount from the M1 consumption instruction, calculates the difference between the M1 balance and the M1 transaction amount, takes the difference between the M1 balance and the M1 transaction amount as the current M1 balance, and writes the current M1 balance as the M1 balance into the M1 storage area.
More specifically, the smart card acquires an M1 wallet original from an M1 wallet original address in an M1 storage area, acquires an M1 balance from an M1 wallet original, acquires an M1 transaction amount from an M1 consumption instruction, calculates a difference value between the M1 balance and the M1 transaction amount, takes the difference value between the M1 balance and the M1 transaction amount as a current M1 balance, takes the current M1 balance as an M1 balance, updates the M1 wallet original according to the updated M1 balance, and writes the updated M1 wallet original to the M1 wallet original address; the smart card acquires an M1 wallet copy from an M1 wallet copy address in an M1 storage area, acquires an M1 balance from the M1 wallet copy, acquires an M1 transaction amount from an M1 consumption instruction, calculates a difference value between the M1 balance and the M1 transaction amount, takes the difference value between the M1 balance and the M1 transaction amount as a current M1 balance, takes the current M1 balance as an M1 balance, updates the M1 wallet copy according to the updated M1 balance, and writes the updated M1 wallet copy into the M1 wallet copy address.
Step 104: the smart card detects whether the M1 transaction status flag is set, if yes, step 107 is executed; otherwise, go to step 105;
step 105: the intelligent card judges whether the M1 balance is larger than the electronic wallet balance or the electronic cash balance, if so, the intelligent card reports an error to the financial terminal and returns to the step 101; otherwise, go to step 106;
specifically, the smart card obtains an M1 balance from the M1 storage area; obtaining the balance of the electronic purse from the first nonvolatile storage area; obtaining an electronic cash balance from the second nonvolatile storage area; judging whether the balance of the M1 is larger than the balance of the electronic wallet or the balance of the electronic cash, if so, reporting an error to the financial terminal, and returning to the step 101; otherwise, go to step 106;
step 106: the intelligent card updates the balance of the electronic wallet to be M1 balance; updating the electronic cash balance to an M1 balance;
specifically, the smart card writes the M1 balance as the electronic wallet balance into the first nonvolatile storage area; the M1 balance is written as an electronic cash balance into the second non-volatile storage area.
Preferably, the first nonvolatile storage area is a Flash storage area of the electronic wallet application; the second nonvolatile storage area is a Flash storage area of the electronic cash application.
Step 107: the smart card selects an application according to the application selection instruction; after the electronic wallet application is selected, returning an application selection success response to the financial terminal, and returning to the step 101; after the electronic cash application is selected, returning an application selection success response to the financial terminal, and returning to the step 101;
specifically, the smart card acquires data on a fifth byte in the application instruction, the data is used as the data length of the application type identifier, the data with the data length being the data length of the application type identifier is acquired from the sixth byte of the application instruction, the acquired data is used as the application type identifier, when the application type identifier is a first preset identifier, the application instruction type is judged to be selected as the electronic wallet application, the electronic wallet application is selected, an application selection success response is returned to the terminal, and the step 101 is returned; when the application type identifier is a second preset identifier, judging that the selected application instruction type is an electronic cash application, selecting the electronic cash application, returning an application selection success response to the terminal, and returning to the step 101;
in this embodiment, the first preset flag is "0 x A000000632010105"; the second preset flag is "0 xA 000000632010106".
For example, the smart card acquires data "08" on the fifth byte in the application instruction as the data length of the application type identifier, starts with selecting the sixth byte of the application instruction "0 x00 a4040008a 000000632010105", acquires data "a 000000632010105" with the data length of 8 bytes, and uses the data as the application type identifier, the application type identifier is the first preset identifier, determines that the selected application instruction type is the electronic wallet application, selects the electronic wallet application, returns a selected application success response to the terminal, and returns to step 101.
Step 108: the intelligent card calculates the balance of the current electronic wallet;
when the electronic wallet transaction instruction is specifically an electronic wallet consumption instruction, the smart card calculates the current electronic wallet balance specifically as follows: the smart card acquires the balance of the electronic wallet from the first nonvolatile storage area, acquires the transaction amount according to the transaction instruction of the electronic wallet, calculates the difference value between the balance of the electronic wallet and the transaction amount, and takes the difference value as the current balance of the electronic wallet.
When the electronic wallet transaction instruction is specifically an electronic wallet load instruction, the smart card calculates the current electronic wallet balance specifically as follows: the smart card acquires the balance of the electronic purse from the first nonvolatile storage area, acquires the transaction amount according to the transaction instruction of the electronic purse, calculates the sum of the balance of the electronic purse and the transaction amount, and takes the sum as the current balance of the electronic purse.
Wherein, calculating the difference between the balance of the electronic purse and the transaction amount, and before taking the difference as the balance of the current electronic purse, the method also comprises the following steps: judging whether the transaction amount is legal, if so, calculating the difference value between the balance of the electronic wallet and the transaction amount, and taking the difference value as the balance of the current electronic wallet; otherwise, reporting an error to the financial terminal;
when the electronic wallet transaction instruction is specifically an electronic wallet consumption instruction, judging whether the transaction amount is legal or not, and specifically comprising the following steps: when the smart card supports the overdraft function, the smart card obtains the overdraft amount, judges whether the transaction amount is not larger than the result of adding a preset overdraft limit to the balance of the electronic wallet and then subtracting the overdraft amount, and if so, judges that the transaction amount is legal; otherwise, judging that the transaction amount is illegal; when the smart card does not support the overdraft function, the smart card judges whether the transaction amount is not greater than the balance of the electronic wallet, and if so, judges that the transaction amount is legal; otherwise, the transaction amount is judged to be illegal.
Before calculating the sum of the balance of the electronic purse and the transaction amount, the method further comprises the following steps: judging whether the transaction amount is legal, if so, calculating the sum of the balance of the electronic wallet and the transaction amount, and taking the sum as the balance of the current electronic wallet; otherwise, reporting an error to the financial terminal;
when the electronic wallet transaction instruction is specifically an electronic wallet loading instruction, judging whether the transaction amount is legal or not, and specifically comprising the following steps: when the smart card supports the overdraft function, the smart card obtains the overdraft amount, the smart card judges whether the transaction amount is not larger than the result of subtracting the sum of the electronic wallet balance and the overdraft amount from the offline preauthorized total amount, and if so, the transaction amount is judged to be legal; otherwise, judging that the transaction amount is illegal; when the smart card does not support the overdraft function, judging whether the transaction amount is not larger than the result of subtracting the balance of the electronic wallet from the preset upper limit of the balance and subtracting the offline preauthorization total amount, if so, judging that the transaction amount is legal; otherwise, the transaction amount is judged to be illegal.
Step 109: the smart card sets the M1 transaction status flag;
step 110: the smart card starts a transaction;
step 111: the smart card updates the M1 balance to the current electronic wallet balance; updating the balance of the electronic cash to the balance of the current electronic wallet; updating the balance of the electronic wallet to the current balance of the electronic wallet;
specifically, the smart card writes the current e-wallet balance as an M1 balance into the M1 storage area; writing the current balance of the electronic wallet into a first nonvolatile storage area as the balance of the electronic wallet; the current electronic wallet balance is written as an electronic cash balance into the second non-volatile storage area.
Step 112: the smart card closes the transaction;
it should be noted that after the transaction is started, if the smart card has a power failure during the process of executing step 111, the transaction may roll back the balance of the electronic wallet and the balance of the electronic cash to the state before the transaction is started.
Step 113: the smart card resets the M1 transaction status flag;
step 114: the smart card returns an electronic wallet transaction success response to the financial terminal, and returns to the step 101;
step 115: the intelligent card calculates the balance of the current electronic cash;
when the electronic cash transaction instruction is specifically an electronic cash consumption instruction, the smart card specifically calculates the current electronic cash balance as follows: the intelligent card acquires the balance of the electronic cash from the second nonvolatile storage area, acquires the transaction amount according to the transaction instruction of the electronic cash, calculates the difference value between the balance of the electronic cash and the transaction amount, and takes the difference value as the balance of the electronic cash.
When the electronic cash transaction instruction is specifically an electronic cash load instruction, the smart card calculates the current electronic cash balance specifically as follows: and the intelligent card acquires the transaction amount according to the electronic cash transaction instruction, and takes the transaction amount as the balance of the current electronic cash.
Wherein, calculating the difference between the electronic cash balance and the transaction amount, and before taking the difference as the current electronic cash balance, the method further comprises: judging whether the transaction amount is legal, if so, calculating the difference between the balance of the electronic cash and the transaction amount, and taking the difference as the balance of the current electronic cash; otherwise, reporting an error to the financial terminal. Correspondingly, when the electronic cash transaction instruction is specifically an electronic cash consumption instruction, judging whether the transaction amount is legal or not, specifically comprising the following steps: when the smart card supports the overdraft function, the smart card acquires the overdraft amount, judges whether the transaction amount is not larger than the result of adding the preset overdraft limit to the balance of the electronic cash and then subtracting the overdraft amount, and judges that the transaction amount is legal if the transaction amount is not larger than the preset overdraft limit; otherwise, judging that the transaction amount is illegal; when the smart card does not support the overdraft function, the smart card judges whether the transaction amount is not greater than the balance of the electronic cash, if so, the transaction amount is judged to be legal; otherwise, the transaction amount is judged to be illegal.
Before the smart card takes the transaction amount as the current electronic cash balance, the method further comprises the following steps: judging whether the transaction amount is legal or not, and if so, taking the transaction amount as the balance of the current electronic cash; otherwise, reporting an error to the financial terminal. Correspondingly, when the electronic cash transaction instruction is specifically an electronic cash load instruction, whether the transaction amount is legal is judged, and the method specifically comprises the following steps: when the smart card supports the overdraft function, the smart card obtains the overdraft amount, the smart card judges whether the transaction amount is not larger than the result of subtracting the offline pre-authorized total amount from the overdraft amount by a preset upper limit of the balance, and if so, the transaction amount is judged to be legal; otherwise, judging that the transaction amount is illegal; when the smart card does not support the overdraft function, judging whether the transaction amount is not larger than the result of subtracting the offline pre-authorized total amount from the preset upper limit of balance, if so, judging that the transaction amount is legal; otherwise, the transaction amount is judged to be illegal.
Step 116: the smart card sets the M1 transaction status flag;
step 117: the smart card starts a transaction;
step 118: the smart card updates the M1 balance to the current electronic cash balance; updating the electronic cash balance to the current electronic cash balance; updating the balance of the electronic wallet to the current balance of the electronic cash;
specifically, the smart card writes the current electronic cash balance as an M1 balance into the M1 storage area; writing the current electronic cash balance as the electronic wallet balance into a first nonvolatile storage area; the current electronic cash balance is written as an electronic cash balance into the second nonvolatile storage area.
Step 119: the smart card closes the transaction;
it should be noted that after the transaction is started, if the smart card fails to power down during the execution of step 118, the transaction may roll back the electronic purse balance and the electronic cash balance to the state before the transaction is started.
Step 120: the smart card resets the M1 transaction status flag;
step 121: the smart card returns an electronic cash transaction success response to the financial terminal, and returns to step 101.
In this embodiment, the electronic wallet consuming instruction includes: a consumption initialization instruction and a consumption instruction; or specifically comprises a composite consumption initialization instruction, a composite application data cache updating instruction and a composite application consumption instruction; the electronic wallet earmark instruction specifically comprises the following steps: a load initialization instruction and a first load instruction;
accordingly:
step 101 specifically includes: the smart card waits for receiving the instruction, and after receiving the application selection instruction from the financial terminal, the smart card executes step 104; when the smart card receives the consumption initialization instruction, the smart card obtains the transaction amount from the consumption initialization instruction, judges whether the transaction amount is legal, if so, returns an initialization success response to the financial terminal, and returns to the step 101; otherwise, reporting an error to the financial terminal, and returning to the step 101; when the smart card receives the consumption instruction, executing step 108; when the intelligent card receives the composite consumption initialization instruction, the intelligent card obtains the transaction amount from the composite consumption initialization instruction, judges whether the transaction amount is legal, if so, returns an initialization success response to the financial terminal, and returns to the step 101; otherwise, reporting an error to the financial terminal, and returning to the step 101; when the smart card receives the composite application consumption instruction, executing step 108; when the smart card receives the load initialization instruction, the smart card obtains the transaction amount from the load initialization instruction, judges whether the transaction amount is legal, if so, returns an initialization success response to the financial terminal, and returns to the step 101; otherwise, reporting an error to the financial terminal, and returning to the step 101; when the smart card receives the first copy-and-load instruction, executing step 108;
step 108 specifically comprises: when the smart card receives the consumption instruction or the composite application consumption instruction, the smart card calculates the difference between the balance of the electronic wallet and the transaction amount, and takes the difference as the balance of the current electronic wallet, and executes step 109; when the smart card receives the first credit balance instruction, the smart card calculates the sum of the balance of the electronic wallet and the transaction amount, and takes the sum as the current balance of the electronic wallet, and executes step 109;
step 101 further comprises: and when the intelligent card receives the instruction of updating the composite application data cache, the intelligent card updates the composite consumption record, returns an update success response to the financial terminal, and returns to the step 101.
In this embodiment, the electronic cash consumption instruction specifically includes: acquiring a processing option instruction and a reading record instruction; or specifically comprises the following steps: reading an extended application recording instruction, acquiring a processing option instruction, updating the extended application recording instruction and reading the recording instruction; the electronic cash loading instruction specifically comprises the following steps: acquiring a processing option instruction, a reading recording instruction, a first application ciphertext generation instruction, a second application ciphertext generation instruction and a second load instruction;
accordingly:
step 101 specifically includes: the smart card waits for the instruction, and after the smart card receives the application selection instruction from the financial terminal, step 104 is executed; when the smart card receives the instruction for acquiring the processing option, the transaction type is judged according to the instruction for acquiring the processing option, when the transaction type is qPBOC transaction, the transaction type identifier is set as a first type identifier, the smart card acquires the transaction amount from the instruction for acquiring the processing option, judges whether the transaction amount is legal, and if so, executes step 115; otherwise, reporting an error to the financial terminal, and returning to the step 101; when the transaction type is qPBOC expanded transaction, setting the transaction type identifier as a second type identifier, acquiring the transaction amount from the acquisition processing option instruction by the smart card, judging whether the transaction amount is legal, and if so, executing the step 115; otherwise, reporting an error to the financial terminal, and returning to the step 101; when the transaction type is a debit and credit transaction, setting the transaction type identifier as a third type identifier, returning an application initialization response to the financial terminal, and returning to the step 101; when the smart card receives the second load instruction, the smart card obtains the transaction amount from the load instruction, judges whether the transaction amount is legal, and if so, executes step 115; otherwise, reporting an error to the financial terminal, and returning to the step 101; when the smart card receives the record reading instruction, detecting a transaction type identifier, and when the transaction type identifier is a first type identifier or a second type identifier, executing step 116; when the transaction type identifier is a third type identifier, returning a read record response to the financial terminal, and returning to the step 101;
the step 115 specifically includes: if the transaction type is qPBOC transaction or qPBOC expansion transaction, when the smart card judges that the transaction amount is legal, the smart card calculates the difference between the electronic cash balance and the transaction amount, takes the difference as the current electronic cash balance, applies an initialization response to the financial terminal, and returns to the step 101; if the transaction type is a debit-credit transaction, and the smart card judges that the transaction amount is legal, the smart card takes the transaction amount as the current electronic cash balance, and step 116 is executed;
step 101 further comprises: when the smart card receives a read extended application record instruction from the financial terminal, returning a read extended application record response to the financial terminal, and returning to the step 101; when the smart card receives an extended application record updating instruction, updating the extended application record, returning an extended application record updating response to the financial terminal, and returning to the step 101; after receiving the first generated application ciphertext instruction, the smart card returns a first generated application ciphertext response to the financial terminal, and returns to the step 101; and after receiving the second application ciphertext generating instruction, the smart card returns a second application ciphertext generating response to the financial terminal, and returns to the step 101.
Example 3
The embodiment provides a method for sharing a balance of multiple accounts in a smart card, as shown in fig. 3 to 5, including:
step 201: the smart card waits for receiving an instruction from the terminal, and executes step 202 after receiving an application selection instruction from the terminal; executing step 301 after receiving a transaction initialization instruction from the terminal; after receiving an acquiring processing option instruction from the terminal, executing step 401;
in the method for sharing a balance of multiple accounts in a smart card provided by this embodiment, the terminal is specifically a financial terminal.
Step 202: the smart card detects whether the M1 transaction status flag is set, and if so, performs step 216; otherwise, go to step 203;
step 203: the smart card acquires an M1 wallet copy address in an M1 storage area from a second storage area of the virtual machine, and acquires an M1 wallet copy according to the M1 wallet copy address;
for example, the smart card acquires the address of the M1 wallet copy in the M1 storage area from the second storage area of the virtual machine, and acquires the M1 wallet copy according to the address of the M1 wallet copy: 0xEC2C000013D3FFFFEC2C000000FF00 FF.
Step 204: the smart card determines whether the M1 wallet copy is legitimate, and if so, performs step 205; otherwise, go to step 206;
specifically, the smart card acquires data on the last four bytes of the electronic wallet copy, judges whether the acquired data is matched with a first preset value, if so, judges that the electronic wallet copy is legal, and executes step 205; otherwise, the electronic wallet copy is determined to be illegal and step 206 is performed.
In this embodiment, preferably, the first preset value is "00 FF00 FF".
For example, the smart card acquires data "0 x00FF00 FF" on the last four bytes of the electronic wallet copy 0x EC2C000013D3FFFFEC2C000000FF00FF, determines that the acquired data matches the first preset value "0 x00FF00 FF", determines that the electronic wallet copy is legal, and then executes step 205.
Step 205: the smart card obtains the M1 balance from the M1 wallet copy; acquiring M1 quota from the first storage area of the virtual machine, and executing step 209;
specifically, the smart card acquires data on the ninth to twelfth bytes of the copy of the M1 wallet, performs reverse processing on the acquired data, and takes the processed data as the balance of M1; the M1 quantum is obtained from the first storage area of the virtual machine and step 209 is performed.
For example: the smart card acquires data 0x EC2C0000 on ninth to twelfth bytes of an M1 wallet copy 0x EC2C000013D3FFFFEC2C000000FF00FF, performs reverse order processing on the acquired data 0x EC2C0000 to obtain processed data 0x00002CEC, and uses the data 0x00002CEC as M1 balance; step 209 is performed by obtaining the M1 quota, 0x00002CEC from the first storage area of the virtual machine.
Step 206: the smart card acquires the M1 wallet original address in the M1 storage area from the second storage area of the virtual machine; obtaining an M1 wallet master according to the M1 wallet master address;
for example, the smart card obtains the M1 wallet master address in the M1 storage area from the second storage area of the virtual machine, and obtains the M1 wallet master from the M1 wallet master address as follows: 0x EC2C000013D3FFFFEC2C000000FF00 FF.
Step 207: the smart card determines whether the M1 wallet certificate is legitimate, and if so, performs step 208; otherwise, go to step 216;
specifically, the smart card acquires data on the last four bytes of the electronic wallet certificate, judges whether the acquired data is matched with a first preset value, if so, judges that the electronic wallet certificate is legal, and executes step 208; otherwise, the electronic wallet is determined to be genuine and illegal, step 216 is performed.
In this embodiment, preferably, the first preset value is "00 FF00 FF".
For example, the smart card acquires data "0 x00FF00 FF" on the last four bytes of the electronic wallet certificate 0x EC2C000013D3FFFFEC2C000000FF00FF, determines that the electronic wallet certificate is legal if the acquired data matches the first preset value "0 x00FF00 FF", and executes step 208.
Step 208: the smart card obtains the M1 balance from the M1 wallet positive; acquiring M1 quota from the first storage area of the virtual machine, and executing step 209;
specifically, the smart card acquires data on the ninth to twelfth bytes of the M1 wallet certificate, performs reverse order processing on the acquired data, and takes the processed data as the balance M1; the M1 quantum is obtained from the first storage area of the virtual machine and step 209 is performed.
For example: the smart card acquires data 0x EC2C0000 on ninth to twelfth bytes of a 0x EC2C000013D3FFFFEC2C000000FF00FF of the M1 wallet certificate, performs reverse order processing on the acquired data 0x EC2C0000 to obtain processed data 0x00002CEC, and uses the data 0x00002CEC as M1 balance; step 209 is performed by obtaining the M1 quota, 0x00002CEC from the first storage area of the virtual machine.
Step 209: the smart card judges whether the M1 balance is greater than or equal to the M1 original amount, if so, the step 214 is executed; otherwise, go to step 210;
step 210: the smart card updates the M1 original amount to M1 balance; writing the updated M1 quota to a first storage area of the virtual machine;
step 211: the smart card determines whether the M1 wallet copy and the M1 wallet copy match, if so, go to step 213; otherwise, go to step 212;
specifically, the smart card determines whether the e-wallet copy and the e-wallet positive copy are consistent, and if so, performs step 213; otherwise, step 212 is performed.
Step 212: the smart card copies the M1 wallet master into the M1 storage area corresponding to the M1 wallet copy address;
step 213: the intelligent card acquires the balance of the electronic wallet from a Flash storage area applied to the electronic wallet; acquiring the balance of the electronic cash from a Flash storage area of the electronic cash application;
for example: the smart card acquires the balance of the electronic wallet from a Flash storage area of the electronic wallet application, wherein the balance is '0 x0002EE 0'; the electronic cash balance is obtained from the Flash storage area of the electronic cash application as "000000012000".
Step 214: the intelligent card judges whether the balance of the M1 is larger than the balance of the electronic wallet or the balance of the electronic cash; if so, reporting an error to the terminal, and ending; otherwise, go to step 215;
for example: the smart card determines that M1 balance 0x00002CEC is not greater than electronic wallet balance 0x0002EE0 or electronic cash balance 000000012000 and proceeds to step 215.
Step 215: the intelligent card updates the balance of the electronic wallet to be M1 balance; updating the electronic cash balance to an M1 balance; writing the balance of the current electronic wallet into a Flash storage area applied to the electronic wallet; writing the current electronic cash balance into a Flash storage area of the electronic cash application;
step 216: the smart card obtains the type of the selected application instruction from the selected application instruction, when the type of the selected application instruction is the electronic wallet application, the electronic wallet application is selected, an application selection success response is returned to the terminal, and the step 201 is returned; when the selected application instruction type is the electronic cash application, selecting the electronic cash application, returning an application selection success response to the terminal, and returning to the step 201;
specifically, the smart card acquires data on the sixth to thirteenth bytes in the application selection instruction, and uses the data as an application type identifier, when the application type identifier is a first preset identifier, it is determined that the application selection instruction type is an electronic wallet application, the electronic wallet application is selected, an application selection success response is returned to the terminal, and the step 201 is returned; when the application type identifier is a second preset identifier, judging that the selected application instruction type is an electronic cash application, selecting the electronic cash application, returning an application selection success response to the terminal, and returning to the step 201;
in this embodiment, the first preset flag is "0 x A000000632010105"; the second preset identification is '0 xA 000000632010106';
for example: the smart card obtains data "0 x A000000632010105" on the sixth to thirteenth bytes in the selected application instruction "0 x 00A4040008A 000000632010105", and takes the data as an application type identifier, the application type identifier is a first preset identifier, the selected application instruction type is judged to be the electronic wallet application, the electronic wallet application is selected, a selected application success response is returned to the terminal, and the step 201 is returned.
Step 301: the smart card judges the type of the transaction initialization instruction, and when the transaction initialization instruction is a consumption initialization instruction, step 302 is executed; when the transaction initialization command is a composite consumption initialization command, executing step 315; when the transaction initialization command is a load initialization command, execute step 329;
specifically, the smart card receives a transaction initialization instruction from the terminal, obtains data on a third byte and a fourth byte in the transaction initialization instruction, determines that the type of the transaction initialization instruction is an application consumption initialization instruction when the data on the third byte and the fourth byte are first consumption identifiers, and executes step 302; when the data on the third byte and the fourth byte are the second consumption identification, judging that the type of the transaction initialization instruction is a composite consumption initialization instruction, and executing step 315; when the data in the third byte and the fourth byte are the load mark, the type of the transaction initialization instruction is determined to be the load initialization instruction, and step 329 is executed.
In this embodiment, the first consumption flag is "0 x 0102"; the second consumption identification is "0 x 0302"; the earmark is "0 x 0002".
For example: the smart card receives a transaction initiation command 0x 805001020b01 from a terminal
0000014f112233445566, obtaining 0102 data of the third byte and the fourth byte in the transaction initiation command, determining the data of the third byte and the fourth byte as the first consumption identifier, determining the type of the transaction initiation command as the consumption initiation command, and executing step 302.
Step 302: the smart card initializes consumption; returning an initialization success response to the terminal;
step 303: the intelligent card receives a consumption instruction from a terminal;
specifically, the smart card waits for receiving an instruction from the terminal, and when receiving a consumption instruction from the terminal, step 304 is executed.
For example: the smart card waits for receiving the command from the terminal, and executes step 304 after receiving the consumption command 0x805401000F 010203042001112315300369EC33E1 from the terminal.
Step 304: the intelligent card obtains the balance of the electronic wallet from a Flash storage area applied to the electronic wallet, obtains the transaction amount from a consumption initialization instruction, calculates the difference value between the balance of the electronic wallet and the transaction amount, and takes the difference value between the balance of the electronic wallet and the transaction amount as the balance of the electronic wallet;
in this step, the transaction amount is obtained from the consumption initialization instruction, specifically: the smart card acquires the data on the seventh to the cross sections in the consumption initialization command as the transaction amount. For example, the smart card acquires the data 02030420 on the seventh to the tenth sections in the consumption initiation command 0x805401000F 010203042001112315300369EC33E1 as the transaction amount.
Step 305: the intelligent card writes the balance of the current electronic wallet into a random storage area;
step 306: the smart card sets the M1 transaction status flag;
step 307: the smart card starts a transaction;
step 308: the smart card writes the current electronic wallet balance into the M1 storage area;
step 309: the smart card acquires M1 original amount from a first storage area of the virtual machine; updating the M1 original amount to the current balance of the electronic purse; writing the updated M1 quota to a first storage area of the virtual machine;
step 310: the intelligent card writes the balance of the current electronic wallet into a Flash storage area in the electronic cash application;
step 311: the smart card writes the balance of the current electronic wallet into a Flash storage area in the electronic wallet application;
step 312: the smart card closes the transaction;
step 313: the smart card resets the M1 transaction status flag;
step 314: and the smart card returns a successful response of the consumption deduction to the terminal, and the process is finished.
Step 315: initializing compound consumption by the smart card; returning an initialization success response to the terminal;
step 316: the intelligent card receives a composite application data updating cache instruction from the terminal, updates the composite consumption record and returns a successful updating response to the terminal;
specifically, the smart card waits for receiving an instruction from the terminal, updates the composite consumption record when receiving an instruction for updating the composite application data cache from the terminal, and returns an update success response to the terminal.
Step 317: the intelligent card receives a composite application consumption instruction from a terminal;
specifically, the smart card waits for receiving an instruction from the terminal, and after receiving a composite application consumption instruction from the terminal, step 318 is executed.
For example: the smart card waits for receiving the command from the terminal, and executes step 318 after the smart card receives the composite application consumption command 0x805401000F 0102030420011123153003C 5A1CEF4 from the terminal.
Step 318: the intelligent card obtains the balance of the electronic wallet from a Flash storage area applied to the electronic wallet, obtains the transaction amount from a composite consumption initialization instruction, calculates the difference value between the balance of the electronic wallet and the transaction amount, and updates the balance of the electronic wallet into the difference value between the balance of the electronic wallet and the transaction amount;
in this step, the transaction amount is obtained from the composite consumption initialization instruction, specifically: and the smart card acquires the data on the seventh to the fourth nodes in the composite consumption initialization command and uses the data as the transaction amount.
Step 319: the smart card writes the balance of the current electronic wallet into a random access memory;
step 320: the smart card sets the M1 transaction status flag;
step 321: the smart card starts a transaction;
step 322: the smart card writes the current electronic wallet balance into the M1 storage area;
step 323: the smart card acquires M1 original amount from a first storage area of the virtual machine; updating the M1 original amount to the current balance of the electronic purse; writing the updated M1 quota to a first storage area of the virtual machine;
step 324: the intelligent card writes the balance of the electronic wallet into a Flash storage area in the electronic cash application;
step 325: the intelligent card writes the balance of the electronic wallet into a Flash storage area in the electronic wallet application;
step 326: the smart card closes the transaction;
step 327: the smart card resets the M1 transaction status flag;
step 328: the intelligent card returns a successful response of composite consumption deduction to the terminal; and (6) ending.
Step 329: initializing the smart card and loading; returning an initialization success response to the terminal;
step 330: the intelligent card receives a first inventory round instruction from a terminal; acquiring the balance of the electronic wallet from an electronic wallet application Flash storage area, acquiring the transaction amount from a load initialization instruction, calculating the sum of the balance of the electronic wallet and the transaction amount, and taking the sum of the balance of the electronic wallet and the transaction amount as the balance of the electronic wallet;
specifically, the smart card waits for receiving an instruction from the terminal, acquires the balance of the electronic wallet from an electronic wallet application Flash storage area after receiving a first credit loading instruction from the terminal, acquires the transaction amount from a credit loading initialization instruction, calculates the sum of the balance of the electronic wallet and the transaction amount, and takes the sum of the balance of the electronic wallet and the transaction amount as the current balance of the electronic wallet.
In this step, the transaction amount is obtained from the earmark initialization instruction, which specifically comprises: and the smart card acquires the data on the seventh to the sixth nodes in the earmark initialization command and uses the data as the transaction amount.
Step 331: the smart card writes the balance of the current electronic wallet into a random access memory;
step 332: the smart card sets the M1 transaction status flag;
step 333: the smart card starts a transaction;
step 334: the smart card writes the current electronic wallet balance into the M1 storage area;
step 335: the smart card acquires M1 original amount from a first storage area of the virtual machine; updating the M1 original amount to the current balance of the electronic purse; writing the updated M1 quota to a first storage area of the virtual machine;
step 336: the intelligent card writes the balance of the current electronic wallet into a Flash storage area in the electronic cash application;
step 337: the smart card writes the balance of the current electronic wallet into a Flash storage area in the electronic wallet application;
step 338: the smart card closes the transaction;
step 339: the smart card resets the M1 transaction status flag;
step 340: and the smart card returns a successful load response to the terminal, and the operation is finished.
Step 401: the smart card judges the transaction type according to the acquisition processing option instruction, and executes step 402 when the transaction type is qPBOC transaction; when the transaction type is a debit transaction, go to step 416;
specifically, the smart card receives an acquisition processing option instruction from the terminal, acquires a data field corresponding to a processing option data object list (PDOL) corresponding to a fourth preset identifier in the acquisition processing option instruction, acquires first valid data corresponding to a fifth preset identifier and second valid data corresponding to a sixth preset identifier from the data field corresponding to the processing option data object list (PDOL), judges whether the transaction type is a qPBOC extended transaction according to the first valid data, sets the transaction type identifier as a second type identifier if the transaction type identifier is the second type identifier, and executes step a 1; otherwise, judging whether the transaction type is qPBOC transaction or debit-credit transaction according to second effective data corresponding to the sixth preset identification, setting the transaction type identification as the first type identification when the transaction type is qPBOC transaction, and executing the step 402; when the transaction type is a debit and credit transaction, setting the transaction type identifier as a third type identifier, and executing step 416;
in this embodiment, the fourth preset flag is "0 x 9F 38", the fifth preset flag is "0 x DF 60", and the sixth preset flag is "0 x 9F 66".
Step 402: the intelligent card initializes the electronic cash application, acquires the balance of the electronic cash from a Flash storage area of the electronic cash application, acquires the transaction amount from the acquisition processing option instruction, and calculates the difference value between the balance of the electronic cash and the transaction amount; taking the difference value between the balance of the electronic cash and the transaction amount as the balance of the electronic cash;
step 403: the smart card writes the current electronic cash balance into a random storage area;
step 404: the intelligent card returns an initialization application response to the terminal;
step 405: the intelligent card receives a reading record instruction from a terminal;
specifically, the smart card waits for receiving an instruction from the terminal, detects the transaction type identifier after receiving a record reading instruction from the terminal, and executes step 406 when the transaction type identifier is the first type identifier.
Step 406: the smart card reads the record according to the record reading instruction, judges whether the last record is read, if yes, executes step 407; otherwise, go on to step 406;
step 407: the smart card sets the M1 transaction status flag;
step 408: the smart card starts a transaction;
step 409: the smart card writes the current electronic cash balance into the M1 storage area;
step 410: the smart card acquires M1 original amount from a first storage area of the virtual machine; updating the M1 original value to the current electronic cash balance; writing the updated M1 quota to a first storage area of the virtual machine;
step 411: the smart card writes the current electronic cash balance into a Flash storage area in the electronic wallet application;
step 412: the intelligent card writes the balance of the current electronic cash into a Flash storage area in the electronic cash application;
step 413: the smart card closes the transaction;
step 414: the smart card resets the M1 transaction status flag;
step 415: the intelligent card returns a reading record response to the terminal; and (6) ending.
Step 416: the intelligent card initializes the electronic cash application and returns an application initialization response to the terminal;
step 417: the intelligent card receives a reading record instruction from the terminal and returns a reading data response to the terminal;
specifically, the smart card waits for receiving an instruction from the terminal, detects the transaction type identifier after receiving a record reading instruction from the terminal, and performs step 418 when the transaction type identifier is the third type identifier.
Step 418: the intelligent card receives a first generated application ciphertext instruction from the terminal and returns a first generated application ciphertext response to the terminal;
specifically, the smart card waits for receiving an instruction from the terminal, and returns a first generated application ciphertext response to the terminal after receiving a first generated application ciphertext instruction from the terminal;
step 419: the intelligent card receives a second application ciphertext generating instruction from the terminal and returns a second application ciphertext generating response comprising the online transaction agreeing information to the terminal;
specifically, the smart card waits for receiving an instruction from the terminal, and when receiving a second application ciphertext generation instruction from the terminal, returns a second application ciphertext generation response including the online transaction approval information to the terminal.
Step 420: the intelligent card receives a second load instruction from the terminal;
specifically, the smart card waits for receiving an instruction from the terminal, and after receiving the instruction from the terminal, determines whether the instruction is a second load instruction, if yes, step 421 is executed; otherwise, other corresponding operations are executed.
More specifically, the smart card waits for receiving an instruction from the terminal, and after receiving the instruction from the terminal, the smart card determines whether data in third and fourth bytes of the received instruction from the terminal is a third preset identifier, and if so, determines that the received instruction from the terminal is a second load instruction, and performs step 421; otherwise, other corresponding operations are executed.
Preferably, the third preset flag is "0 x 9F 79".
For example, the smart card waits for receiving a command from the terminal, and when the command from the terminal is received, if the data in the third and fourth bytes of the command 0x04DA9F790a 000000050000D 03766E4 is determined to be the third preset identifier, the received command from the terminal is determined to be the second load command, and step 421 is executed.
Step 421: the smart card obtains the transaction amount from the second load instruction;
specifically, the smart card acquires the data on the sixth to eleventh bytes in the second load instruction as the transaction amount.
For example: the smart card acquires data 0x000000050000 on the sixth to eleventh bytes in the second load instruction 0x04DA9F790a00000005000000D03766E4 as the transaction amount.
Step 422: the intelligent card takes the transaction amount as the current electronic cash balance and writes the current electronic cash balance into the random access memory;
step 423: the smart card sets the M1 transaction status flag;
step 424: the smart card starts a transaction;
step 425: the smart card writes the current electronic cash balance into the M1 storage area;
step 426: the smart card acquires M1 original amount from a first storage area of the virtual machine; updating the M1 original value to the current electronic cash balance; writing the updated M1 quota to a first storage area of the virtual machine;
step 427: the smart card writes the current electronic cash balance into a Flash storage area in the electronic wallet application;
step 428: the intelligent card writes the balance of the current electronic cash into a Flash storage area in the electronic cash application;
step 429: the smart card closes the transaction;
step 430: the smart card resets the M1 transaction status flag;
step 431: and the smart card returns a load response to the terminal, and the operation is finished.
In this embodiment, step 401 further includes: when the transaction type is the qPBOC extended transaction, executing the step a 1;
step a 1: the intelligent card initializes the electronic cash application, acquires the balance of the electronic cash from a Flash storage area of the electronic cash application, acquires the transaction amount from the acquisition processing option instruction, and calculates the difference value between the balance of the electronic cash and the transaction amount; updating the balance of the electronic cash to be a difference value between the balance of the electronic cash and the transaction amount;
step a 2: the smart card writes the current electronic cash balance into the random access memory;
step a 3: the intelligent card returns an initialization application response to the terminal;
step a 4: the intelligent card receives an update extended application record instruction from the terminal;
step a 5: the smart card updates the extended application record, judges whether the last extended application record is updated, if yes, executes step a 6; otherwise, continuing to execute step a 5;
step a 6: the smart card returns an update extended application record response to the terminal, and step 405 is executed.
Correspondingly, step 405 specifically includes: the smart card waits for receiving an instruction from the terminal, detects the transaction type identifier after receiving a record reading instruction from the terminal, and executes step 406 when the transaction type identifier is the second type identifier.
When the transaction type is the qPBOC extended transaction, before executing step 401, the method further includes:
step b 1: the intelligent card receives a reading expansion application recording instruction from a terminal;
step b 2: the smart card judges whether the last extended application record is read or not, if so, returns an extended application record reading response to the terminal, and executes the step 401; otherwise, execution continues with step b 2.
In this embodiment, step 205 may also be replaced with: the smart card obtains the M1 balance from the M1 wallet copy; correspondingly: step 208 may also be replaced with: the smart card obtains the balance of M1 from the positive text of the M1 wallet, and step 211 is executed; after the step 308 is executed, the step 310 is directly executed; after step 322, step 324 is performed directly; after step 334, step 336 is performed directly; step 411 is executed directly after step 409; step 427 is performed directly after step 425.
In the method for sharing the balance of the multiple accounts in the smart card, the balance of M1, the balance of an electronic purse and the balance of electronic cash in the card can be shared. For example: after the intelligent card is consumed by using the M1 terminal, the M1 balance, the electronic wallet balance and the electronic cash balance in the card also synchronously change, and after the intelligent card is consumed by a financial terminal, the M1 balance, the electronic wallet balance and the electronic cash balance in the card also synchronously change, so that the intelligent card can be used on a terminal supporting electronic cash application, a terminal supporting electronic wallet application and a terminal supporting an encryption memory card, and the technical problems that an industrial card is high in maintenance cost, serious in resource waste, easy to crack the M1 card and the like are solved.
Example 4
The embodiment provides a smart card, as shown in fig. 6: the system comprises a first receiving module 01, a second receiving module 02, a first detecting module 03, a first judging module 04, a first error reporting module 05, a first updating module 06, a first application module 07, a first returning module 08, a first calculating module 09, a first transaction module 10, a first setting module 11, a second updating module 12 and a second returning module 13;
the first receiving module 01 is used for receiving an application selection instruction from a financial terminal;
the second receiving module 02 is used for receiving an application transaction instruction from the financial terminal;
the first detecting module 03 is configured to detect whether an M1 transaction status flag of the first receiving module 01 is set after the first receiving module receives the application selection instruction;
the first judging module 04 is configured to judge a size relationship between the M1 balance of the first judging module, the electronic wallet balance, and the electronic cash balance of the first judging module 03 after the first judging module detects that the first judging module does not detect the electronic wallet balance;
the first judgment module 04 includes: the device comprises a first acquisition unit, a second acquisition unit, a third acquisition unit and a first judgment unit;
a first obtaining unit, configured to obtain the M1 balance from the M1 storage area when the first detecting module 03 detects no;
further, the first acquisition unit includes: the system comprises a first acquisition subunit, a first judgment subunit, a second acquisition subunit, a third acquisition subunit, a second judgment subunit and a fourth acquisition subunit;
a first acquiring subunit, configured to acquire an address of the M1 wallet copy in the M1 storage area and acquire an M1 wallet copy according to the address of the M1 wallet copy, when the first detecting module 03 detects no;
a first judgment subunit, configured to judge whether the M1 wallet copy is legal;
a second acquiring subunit, configured to acquire the balance M1 from the copy M1 wallet, when the first determining subunit determines that the balance is positive;
a third acquiring subunit operable to acquire the M1 wallet home address in the M1 storage area, when judged by the first judging subunit as no; obtaining an M1 wallet master according to the M1 wallet master address;
a second judgment subunit, configured to judge whether the M1 wallet master is legal;
a fourth acquiring subunit configured to acquire the balance M1 from the positive text of the M1 wallet, when the second judging subunit judges yes;
correspondingly, the first application module 07 is further configured to select an application according to the application selection instruction after the second determining subunit determines that the application is not selected.
Still further, the smart card may further include: a first recovery module;
and the first recovery module is used for writing the original of the M1 wallet into the copy address of the M1 wallet as the copy of the M1 wallet before the first judgment module 04 judges the magnitude relation among the balance of the M1, the balance of the electronic wallet and the balance of electronic cash after the second judgment subunit judges that the second judgment subunit is positive.
The second acquisition unit is used for acquiring the balance of the electronic purse from the first nonvolatile storage area after the first detection module 03 detects no;
the third acquisition unit is used for acquiring the balance of the electronic cash from the second nonvolatile storage area after the first detection module 03 detects no;
a first judgment unit for judging whether the M1 balance is greater than the electronic wallet balance or the electronic cash balance.
A first updating module 06, configured to update the balance of the electronic wallet to the balance of M1 when the first determining module 04 determines that the balance of M1 is minimum; updating the electronic cash balance to an M1 balance;
the first update module 06 is specifically configured to: when the first judgment module 04 judges that the balance of the M1 is minimum, writing the balance of the M1 as the balance of the electronic wallet into the first nonvolatile storage area; the M1 balance is written as an electronic cash balance into the second non-volatile storage area.
The first application module 07 is configured to, when the first determining module 04 determines that the M1 balance, the electronic wallet balance, and the electronic cash balance are equal to each other, and the first updating module 06 updates the electronic wallet balance and the electronic cash balance, select an application according to the application selection instruction;
the first error reporting module 05 is configured to report an error to the financial terminal when the first determining module 04 determines that the balance of the M1 is greater than the balance of the electronic wallet or the balance of the electronic cash;
the first returning module 08 is used for returning an application selection success response to the financial terminal after the first application module 07 selects an application according to the application selection instruction;
the first calculation module 09 is used for calculating the balance of the current account according to the transaction amount in the application transaction instruction; the current account balance is the current electronic wallet balance or the current electronic cash balance;
the first setting module 11 is configured to set an M1 transaction status flag after the first calculation module 09 calculates the current account balance; when the first transaction module 10 closes the transaction, the M1 transaction status flag is reset;
the first transaction module 10 is configured to start a transaction after the first calculation module 09 calculates the current account balance; when the second updating module 12 respectively updates the M1 balance, the electronic wallet balance and the electronic cash balance to the current account balance, closing the transaction;
the second updating module 12 is configured to update the M1 balance, the electronic wallet balance, and the electronic cash balance to the current account balance respectively after the first transaction module 10 starts a transaction;
the second updating module 12 is specifically configured to: when the current account balance is the current electronic wallet balance after the first transaction module 10 starts the transaction, writing the current electronic wallet balance as the M1 balance into the M1 storage area; writing the current balance of the electronic wallet into a first nonvolatile storage area as the balance of the electronic wallet; writing the current electronic wallet balance as an electronic cash balance into a second non-volatile storage area; when the current account balance is the current electronic cash balance, writing the current electronic cash balance into an M1 storage area as an M1 balance; writing the current electronic cash balance as the electronic wallet balance into a first nonvolatile storage area; the current electronic cash balance is written as an electronic cash balance into the second nonvolatile storage area.
And a second returning module 13, configured to return a transaction success response to the financial terminal after the second updating module 12 updates the M1 balance, the electronic wallet balance, and the electronic cash balance to the current account balance, respectively.
In this embodiment, the smart card may further include a third receiving module, a second detecting module, a second calculating module, a third updating module, a second error reporting module, and a third returning module;
a third receiving module, configured to receive an M1 consumption instruction from an M1 terminal;
the second detection module is used for detecting whether the own M1 transaction state flag is set or not after the third receiving module receives the M1 consumption instruction;
the second error reporting module is used for reporting an error to the M1 terminal after the second detection module detects that the second detection module;
the second calculation module is used for calculating the balance of the current M1 after the second detection module detects that the balance is negative;
the second calculating module is specifically configured to, after the second detecting module detects that the balance is negative, obtain the M1 balance from the M1 storage area, obtain the M1 transaction amount from the M1 consumption instruction, calculate a difference between the M1 balance and the M1 transaction amount, and use the difference between the M1 balance and the M1 transaction amount as the current M1 balance;
a third updating module for updating the M1 balance to the current M1 balance;
and the third updating module is specifically used for writing the current M1 balance into the M1 storage area as the M1 balance.
And the third returning module is used for returning the consumption success information to the M1 terminal.
In this embodiment, the smart card may further include: a second judgment module;
the second judgment module is used for judging whether the transaction amount in the application transaction instruction is legal or not;
the first calculating module 09 is specifically configured to calculate the current account balance according to the transaction amount in the application transaction instruction after the second judging module judges that the current account balance is the current account balance;
the first error reporting module 05 is further configured to report an error to the financial terminal after the second determining module determines that the first error is not correct.
Further, applying the transaction instructions comprises: an electronic wallet consumption instruction or an electronic wallet loading instruction or an electronic cash consumption instruction or an electronic cash loading instruction; when the smart card supports the overdraft function:
the second judgment module is specifically configured to: when the application transaction instruction is an electronic wallet consumption instruction, judging whether the transaction amount is not larger than the result of adding the overdraft limit to the balance of the electronic wallet and then subtracting the overdraft amount, and if so, judging that the transaction amount is legal; otherwise, judging that the transaction amount is illegal; when the application transaction instruction is an electronic wallet load instruction, judging whether the transaction amount is not larger than the result of subtracting the sum of the balance of the electronic wallet from the balance of the electronic wallet and subtracting the sum of the overdrawn amount from the offline preauthorization total amount, and if so, judging that the transaction amount is legal; otherwise, judging that the transaction amount is illegal;
when the application transaction instruction is an electronic cash consumption instruction, judging whether the transaction amount is not larger than the result of adding the overdraft limit to the electronic cash balance and then subtracting the overdraft amount, and if so, judging that the transaction amount is legal; otherwise, judging that the transaction amount is illegal;
when the application transaction instruction is an electronic cash load instruction, judging whether the transaction amount is not larger than the result of adding the balance upper limit to the overdrawn amount and subtracting the offline pre-authorization total amount, and if so, judging that the transaction amount is legal; otherwise, the transaction amount is judged to be illegal.
Further, applying the transaction instructions comprises: an electronic wallet consumption instruction or an electronic wallet loading instruction or an electronic cash consumption instruction or an electronic cash loading instruction; when the smart card does not support the overdraft function:
the second judgment module is specifically configured to: when the application transaction instruction is an electronic wallet consumption instruction, judging whether the transaction amount is not greater than the balance of the electronic wallet, and if so, judging that the transaction amount is legal; otherwise, judging that the transaction amount is illegal;
when the application transaction instruction is an electronic wallet load instruction, judging whether the transaction amount is not larger than the result of subtracting the electronic wallet balance from the balance upper limit and subtracting the offline pre-authorization total amount, and if so, judging that the transaction amount is legal; otherwise, judging that the transaction amount is illegal;
when the application transaction instruction is an electronic cash consumption instruction, judging whether the transaction amount is not greater than the balance of the electronic cash, and if so, judging that the transaction amount is legal; otherwise, judging that the transaction amount is illegal;
when the application transaction instruction is an electronic cash loading instruction, judging whether the transaction amount is not larger than the result of subtracting the offline pre-authorized total amount from the upper limit of the balance, and if so, judging that the transaction amount is legal; otherwise, the transaction amount is judged to be illegal.
In this embodiment, the application transaction instruction may specifically include: an electronic wallet consumption instruction or an electronic wallet earmark instruction;
the first calculating module 09 is specifically configured to calculate a difference between the balance of the electronic wallet and the transaction amount when the application transaction instruction is an electronic wallet consumption instruction, and use the difference as the current balance of the electronic wallet;
and when the application transaction instruction is specifically an electronic wallet loading instruction, calculating the sum of the balance of the electronic wallet and the transaction amount, and taking the sum as the current balance of the electronic wallet.
Further, the smart card further comprises: the device comprises a first acquisition module and a third judgment module; correspondingly: the electronic wallet consumption instruction comprises the following steps: a consumption initialization instruction and a consumption instruction; or specifically comprises a composite consumption initialization instruction, a composite application data cache updating instruction and a composite application consumption instruction; the electronic wallet earmark instruction specifically comprises the following steps: a load initialization instruction and a first load instruction;
the second receiving module 02 includes: a first receiving unit, a second receiving unit, a third receiving unit, a fourth receiving unit, a fifth receiving unit, a sixth receiving unit and a seventh receiving unit;
the second return module 13 includes: a first return unit, a second return unit, and a third return unit;
a first receiving unit for receiving a consumption initialization instruction from a financial terminal;
a second receiving unit for receiving a consumption instruction from the financial terminal;
the third receiving unit is used for receiving a composite consumption initialization instruction from the financial terminal;
the fourth receiving unit is used for receiving the composite application consumption instruction from the financial terminal;
the fifth receiving unit is used for receiving the load initialization instruction from the financial terminal;
a sixth receiving unit, configured to receive the first credit worthiness instruction from the financial terminal;
the first acquisition module is used for acquiring the transaction amount from the consumption initialization instruction after the first receiving unit receives the consumption initialization instruction; when the third receiving unit receives the composite consumption initialization instruction, the transaction amount is obtained from the composite consumption initialization instruction; when the fifth receiving unit receives the load initialization instruction from the financial terminal, the transaction amount is obtained from the load initialization instruction;
the third judging module is used for judging whether the transaction amount acquired by the first acquiring module is legal or not;
the first returning unit is used for returning an initialization success response to the financial terminal after the third judging module judges that the first judging module is positive;
the first error reporting module 05 is further configured to report an error to the financial terminal after the third determining module determines that the third determining module is not;
the first calculating module 09 is specifically configured to calculate a difference between the balance of the electronic wallet and the transaction amount when the second receiving unit receives the consumption instruction or when the fourth receiving unit receives the composite application consumption instruction, and use the difference as the current balance of the electronic wallet; when the sixth receiving unit receives the first credit balance instruction, the sum of the balance of the electronic wallet and the transaction amount is calculated and is used as the balance of the current electronic wallet;
a second returning unit, configured to return a successful transaction response to the financial terminal after the first transaction module 10 closes the transaction;
a seventh receiving unit, configured to receive an instruction to update the composite application data cache from the financial terminal;
and the third returning unit is used for returning an updating success response to the financial terminal after the composite consumption record is updated.
In this embodiment, the applying the transaction instruction may further specifically include: an electronic cash consumption instruction or an electronic cash loading instruction;
the first calculation module 09 is specifically configured to calculate a difference between an electronic cash balance and a transaction amount when the application transaction instruction is an electronic cash consumption instruction, and use the difference as the current electronic cash balance; and when the transaction instruction is specifically an electronic cash load instruction, taking the transaction amount as the current electronic cash balance.
Further, the smart card further comprises: the device comprises a fourth judging module, a second setting module, a second obtaining module, a fifth judging module and a third detecting module; correspondingly, the electronic cash consumption instruction specifically comprises: acquiring a processing option instruction and a reading record instruction; or specifically comprises the following steps: reading an extended application recording instruction, acquiring a processing option instruction, updating the extended application recording instruction and reading the recording instruction; the electronic cash loading instruction specifically comprises the following steps: acquiring a processing option instruction, a reading recording instruction, a first application ciphertext generation instruction, a second application ciphertext generation instruction and a second load instruction;
the second receiving module 02 includes: an eighth receiving unit, a ninth receiving unit, a tenth receiving unit, an eleventh receiving unit, a twelfth receiving unit, a thirteenth receiving unit, and a fourteenth receiving unit;
the second return module 13: the system comprises a fourth return unit, a fifth return unit, a sixth return unit, a seventh return unit, an eighth return unit, a ninth return unit and a tenth return unit;
an eighth receiving unit, configured to receive an acquisition processing option instruction from the financial terminal;
a ninth receiving unit for receiving a read record instruction from the financial terminal;
a tenth receiving unit, configured to receive the second load instruction from the financial terminal;
the fourth judging module is used for judging the transaction type according to the acquisition processing option instruction;
the second setting module is used for setting the transaction type identifier as the first type identifier when the fourth judging module judges that the transaction type is the qPBOC transaction; when the fourth judging module judges that the transaction type is the qPBOC expanded transaction, setting the transaction type identifier as a second type identifier; setting the transaction type identifier as a third type identifier when the transaction type is a debit and credit transaction;
the second obtaining module is used for obtaining the transaction amount from the obtaining processing option instruction when the fourth judging module judges that the transaction type is qPBOC transaction or qPBOC expansion transaction; when the fourth judging module judges that the transaction type is debit and credit transaction, the transaction amount is obtained from the second load instruction;
the fifth judging module is used for judging whether the transaction amount acquired by the second acquiring module is legal or not;
the first calculating unit is specifically used for calculating a difference value between the electronic cash balance and the transaction amount and taking the difference value as the current electronic cash balance if the transaction type is qPBOC transaction or qPBOC expanded transaction; if the transaction type is a debit and credit transaction, taking the transaction amount as the balance of the current electronic cash after the fifth judgment module judges that the transaction type is the debit and credit transaction;
the fourth returning unit is used for returning an application initialization response to the financial terminal after the fourth judging module judges that the transaction type is the debit and credit transaction; when the fourth judging module judges that the transaction type is qPBOC transaction or qPBOC expansion transaction, the first calculating unit calculates the difference value between the electronic cash balance and the transaction amount, and the difference value is used as the current electronic cash balance, and then application initialization response is returned to the financial terminal;
the first error reporting module 05 is further configured to report an error to the financial terminal when the fifth determining module determines that the financial terminal is not the financial terminal;
the third detection module is used for detecting the transaction type identifier after the ninth receiving unit receives the record reading instruction;
the second updating module 12 is specifically configured to update the balance of M1, the balance of the electronic wallet, and the balance of the electronic cash to the current balance of the electronic cash respectively after the third detecting module detects that the transaction type identifier is the first type identifier or the second type identifier; when the first calculation unit takes the transaction amount as the current electronic cash balance, respectively updating the M1 balance, the electronic wallet balance and the electronic cash balance as the current electronic cash balance;
the fifth returning unit is used for returning a reading record response to the financial terminal after the third detection module detects that the transaction type identifier is the third type identifier; when the third detection module detects that the transaction type identifier is the first type identifier or the second type identifier, and when the first setting module 11 resets the M1 transaction state flag, a read record response is returned to the financial terminal;
a sixth returning unit, configured to return a load response to the financial terminal after the tenth receiving unit receives the second load instruction;
an eleventh receiving unit, configured to receive a read extended application recording instruction from the financial terminal;
a seventh returning unit, configured to return a read extended application record response to the financial terminal;
a twelfth receiving unit, configured to receive an update extended application record instruction from the financial terminal;
the eighth returning unit is used for returning an update extended application record response to the financial terminal after the extended application record is updated;
a thirteenth receiving unit, configured to receive the first generated application cryptogram instruction from the financial terminal;
a ninth returning unit, configured to return the first generated application ciphertext response to the financial terminal;
a fourteenth receiving unit, configured to receive a second application ciphertext generating instruction from the financial terminal;
and the tenth returning unit is used for returning the second generated application ciphertext response to the financial terminal.
The embodiment provides a smart card, and M1 balance, electronic purse balance and electronic cash balance share in the smart card enable the smart card to be used on a terminal supporting an electronic cash application, a terminal supporting an encrypted memory card and a terminal supporting an electronic purse application.
The above description is only for the preferred embodiment of the present invention, but the scope of the present invention is not limited thereto, and any changes or substitutions that can be easily conceived by those skilled in the art within the technical scope of the present invention are included in the scope of the present invention. Therefore, the protection scope of the present invention shall be subject to the protection scope of the claims.
Claims (24)
1. A method for sharing balance of multiple accounts in a smart card is characterized by comprising the following steps:
step s 1: the smart card receives the instruction, and after the smart card receives the application selection instruction from the financial terminal, the step s2 is executed; when the smart card receives the application transaction instruction from the financial terminal, executing step s 6;
step s 2: the smart card detects whether the self M1 transaction status flag is set, if so, the step s5 is executed; otherwise, go to step s 3;
step s 3: the smart card judges the relationship among the balance of the smart card M1, the balance of the electronic wallet and the balance of the electronic cash, and if the balance of the smart card M1 is minimum, the step s4 is executed; if the M1 balance, the electronic wallet balance and the electronic cash balance are equal, executing step s 5; if the balance of the M1 is greater than the balance of the electronic wallet or the balance of the electronic cash, reporting an error to the financial terminal, and ending;
step s 4: the smart card updating the electronic wallet balance to the M1 balance; updating the electronic cash balance to the M1 balance;
step s 5: the intelligent card selects the application according to the application selection instruction, returns an application selection success response to the financial terminal and returns to the step s 1;
step s 6: the intelligent card calculates the balance of the current account according to the transaction amount in the application transaction instruction; the current account balance is the current electronic wallet balance or the current electronic cash balance;
step s 7: the smart card locates the M1 transaction status flag to start the transaction;
step s 8: the smart card respectively updates the M1 balance, the electronic wallet balance and the electronic cash balance to the current account balance;
step s 9: the smart card closes the transaction; after closing the transaction, resetting the M1 transaction state mark, returning a successful transaction response to the financial terminal, and ending;
the step s1 further includes: after receiving the M1 consumption command from the M1 terminal, executing the step r 1;
step r 1: the smart card detects whether an own M1 transaction state flag is set, and if so, an error is reported to the M1 terminal; otherwise, go to step r 2;
step r 2: the smart card calculates the current M1 balance, updates the M1 balance into the current M1 balance, and returns consumption success information to the M1 terminal;
the calculating of the current M1 balance and the updating of the M1 balance to the current M1 balance specifically include: the smart card acquires an M1 balance from an M1 storage area, acquires an M1 transaction amount from an M1 consumption instruction, calculates a difference value between the M1 balance and the M1 transaction amount, takes the difference value between the M1 balance and the M1 transaction amount as a current M1 balance, and writes the current M1 balance into an M1 storage area as an M1 balance.
2. The method according to claim 1, wherein step s3 is specifically:
the smart card obtains the M1 balance from an M1 storage area; obtaining the electronic wallet balance from a first non-volatile storage area; obtaining the electronic cash balance from a second nonvolatile storage area; judging whether the balance of the M1 is larger than the balance of the electronic wallet or the balance of the electronic cash, if so, reporting an error to the financial terminal; otherwise: if the M1 balance is less than the electronic wallet balance and the M1 balance is less than the electronic cash balance, then execute step s 4; if the M1 balance is equal to the electronic wallet balance and the M1 balance is equal to the electronic cash balance, then step s5 is performed.
3. The method according to claim 2, wherein the obtaining the M1 balance from the M1 storage area specifically comprises:
step s 31: the smart card acquires an address of the M1 wallet copy in the M1 storage area, and acquires an M1 wallet copy according to the address of the M1 wallet copy;
step s 32: the smart card judges whether the M1 wallet copy is legal, if so, the step s33 is executed; otherwise, go to step t 31;
step s 33: the smart card obtains the M1 balance from the M1 wallet copy;
step t 31: the smart card obtains the M1 wallet home address in the M1 storage area; acquiring an M1 wallet master according to the M1 wallet master address;
step t 32: the smart card determines whether the M1 wallet certificate is legitimate, and if so, performs step t 33; otherwise, go to step s 5;
step t 33: the smart card obtains the M1 balance from the M1 wallet copy.
4. The method as claimed in claim 3, wherein after the step t32 judges that the wallet account of M1 is legal, before the step t32 judges the relationship between the M1 balance, the electronic wallet balance and the electronic cash balance, the method further comprises: the smart card copies the M1 wallet copy to the M1 wallet copy address.
5. The method of claim 1, wherein said updating said wallet balance to said M1 balance; updating the electronic cash balance to the M1 balance, specifically: the smart card writes the M1 balance as an electronic wallet balance into a first non-volatile storage area; writing the M1 balance as an electronic cash balance into a second non-volatile storage area;
respectively updating the M1 balance, the electronic wallet balance and the electronic cash balance to the current account balance, specifically: when the current account balance is the current e-wallet balance, the smart card writing the current e-wallet balance as an M1 balance into an M1 storage area; writing the current balance of the electronic wallet into a first nonvolatile storage area as the balance of the electronic wallet; writing the current e-wallet balance as an electronic cash balance into a second non-volatile storage area;
when the current account balance is the current electronic cash balance, the smart card writes the current electronic cash balance as an M1 balance into an M1 storage area; writing the current electronic cash balance into a first nonvolatile storage area as an electronic wallet balance; writing the current electronic cash balance as an electronic cash balance into a second non-volatile storage area.
6. The method according to claim 1, wherein said step s6 is preceded by the further step of: judging whether the transaction amount in the application transaction instruction is legal, if so, executing a step s 6; otherwise, reporting an error to the financial terminal, and ending.
7. The method of claim 6, wherein applying the transaction instructions comprises: an electronic wallet consumption instruction or an electronic wallet earmark instruction or an electronic cash consumption instruction or an electronic cash earmark instruction;
when the application transaction instruction is the electronic wallet consumption instruction, the judging whether the transaction amount in the application transaction instruction is legal specifically comprises the following steps: the intelligent card judges whether the transaction amount is not larger than the result of adding the overdraft limit to the balance of the electronic wallet and then subtracting the overdraft amount, if so, the transaction amount is judged to be legal; otherwise, judging that the transaction amount is illegal;
when the application transaction instruction is the electronic wallet loading instruction, the specific step of judging whether the transaction amount in the application transaction instruction is legal is as follows: the intelligent card judges whether the transaction amount is not larger than a result obtained by subtracting the sum of the balance of the electronic wallet from the upper limit of the balance and subtracting the sum of offline pre-authorization from the overdrawn amount, and if so, judges that the transaction amount is legal; otherwise, judging that the transaction amount is illegal;
when the application transaction instruction is the electronic cash consumption instruction, the step of judging whether the transaction amount in the application transaction instruction is legal specifically comprises the following steps: the intelligent card judges whether the transaction amount is not larger than the result of adding the overdraft limit to the electronic cash balance and then subtracting the overdraft amount, if so, the transaction amount is judged to be legal; otherwise, judging that the transaction amount is illegal;
when the application transaction instruction is the electronic cash load instruction, the step of judging whether the transaction amount in the application transaction instruction is legal specifically comprises the following steps: the intelligent card judges whether the transaction amount is not larger than the result of adding the balance upper limit to the overdrawn amount minus the offline pre-authorized total amount, and if so, judges that the transaction amount is legal; otherwise, judging that the transaction amount is illegal.
8. The method of claim 6, wherein applying the transaction instructions comprises: an electronic wallet consumption instruction or an electronic wallet earmark instruction or an electronic cash consumption instruction or an electronic cash earmark instruction;
when the application transaction instruction is the electronic wallet consumption instruction, the judging whether the transaction amount in the application transaction instruction is legal specifically comprises the following steps: the intelligent card judges whether the transaction amount is not larger than the balance of the electronic wallet, and if so, judges that the transaction amount is legal; otherwise, judging that the transaction amount is illegal;
when the application transaction instruction is the electronic wallet loading instruction, the specific step of judging whether the transaction amount in the application transaction instruction is legal is as follows: the intelligent card judges whether the transaction amount is not larger than a result obtained by subtracting the sum of the electronic wallet from the upper limit of the balance and subtracting the total offline pre-authorization amount, and if so, the transaction amount is judged to be legal; otherwise, judging that the transaction amount is illegal;
when the application transaction instruction is the electronic cash consumption instruction, the step of judging whether the transaction amount in the application transaction instruction is legal specifically comprises the following steps: the intelligent card judges whether the transaction amount is not greater than the balance of the electronic cash, and if so, judges that the transaction amount is legal; otherwise, judging that the transaction amount is illegal;
when the application transaction instruction is the electronic cash load instruction, the step of judging whether the transaction amount in the application transaction instruction is legal specifically comprises the following steps: the intelligent card judges whether the transaction amount is not larger than a result obtained by subtracting the offline pre-authorization total amount from the upper limit of the balance or not, and if so, judges that the transaction amount is legal; otherwise, judging that the transaction amount is illegal.
9. The method of claim 1, wherein applying the transaction instructions comprises: an electronic wallet consumption instruction or an electronic wallet loading instruction;
when the application transaction instruction is the electronic wallet consumption instruction, calculating the current account balance according to the transaction amount in the application transaction instruction, specifically: calculating the difference value between the balance of the electronic purse and the transaction amount, and taking the difference value as the balance of the current electronic purse;
when the application transaction instruction is specifically the electronic wallet load instruction, calculating the current account balance according to the transaction amount in the application transaction instruction, specifically: and calculating the sum of the balance of the electronic purse and the transaction amount, and taking the sum as the balance of the current electronic purse.
10. The method of claim 9, wherein the wallet consuming instructions comprise: a consumption initialization instruction and a consumption instruction; or specifically comprises a composite consumption initialization instruction, a composite application data cache updating instruction and a composite application consumption instruction; the electronic wallet earmark instruction specifically comprises the following steps: a load initialization instruction and a first load instruction;
the step s1 specifically includes: the smart card waits for receiving the instruction, and after receiving the application selection instruction from the financial terminal, the smart card executes step s 2; when the smart card receives the consumption initialization instruction, the smart card obtains the transaction amount from the consumption initialization instruction, judges whether the transaction amount is legal, if so, returns an initialization success response to the financial terminal, and returns to step s 1; otherwise, reporting an error to the financial terminal, and returning to the step s 1; when the smart card receives the consumption instruction, executing step s 6; when the intelligent card receives the composite consumption initialization instruction, the intelligent card obtains the transaction amount from the composite consumption initialization instruction, judges whether the transaction amount is legal, returns an initialization success response to the financial terminal if the transaction amount is legal, and returns to the step s 1; otherwise, reporting an error to the financial terminal, and returning to the step s 1; when the smart card receives the composite application consumption instruction, executing step s 6; when the smart card receives the load initialization instruction, the smart card obtains the transaction amount from the load initialization instruction, judges whether the transaction amount is legal, if so, returns an initialization success response to the financial terminal, and returns to the step s 1; otherwise, reporting an error to the financial terminal, and returning to the step s 1; when the smart card receives the first load instruction, executing step s 6;
step s6 specifically includes: when the smart card receives the consumption instruction or the composite application consumption instruction, the smart card calculates a difference value between the balance of the electronic wallet and the transaction amount, and takes the difference value as the balance of the electronic wallet, and executes step s 7;
when the smart card receives the first credit balance instruction, the smart card calculates the sum of the balance of the electronic purse and the transaction amount, and takes the sum as the balance of the current electronic purse, and executes step s 7;
the step s1 further includes: and when the intelligent card receives the composite application data cache updating instruction, the intelligent card updates the composite consumption record, returns an updating success response to the financial terminal, and returns to the step s 1.
11. The method of claim 1, wherein applying the transaction instructions comprises: an electronic cash consumption instruction or the electronic cash loading instruction;
when the application transaction instruction is specifically the electronic cash consumption instruction, the step s6 is specifically: the intelligent card calculates the difference between the balance of the electronic cash and the transaction amount, and takes the difference as the balance of the current electronic cash;
when the application transaction instruction is specifically the electronic cash load instruction, the step s6 is specifically: the smart card takes the transaction amount as the current electronic cash balance.
12. The method of claim 11, wherein the electronic cash consumption instructions specifically include: acquiring a processing option instruction and a reading record instruction; or specifically comprises the following steps: reading an extended application recording instruction, acquiring a processing option instruction, updating the extended application recording instruction and reading the recording instruction;
the electronic cash loading instruction specifically comprises the following steps: acquiring a processing option instruction, a reading recording instruction, a first application ciphertext generation instruction, a second application ciphertext generation instruction and a second load instruction;
the step s1 specifically includes: the smart card waits for receiving the instruction, and after receiving the application selection instruction from the financial terminal, the smart card executes step s 2; when the smart card receives the acquiring and processing option instruction, the transaction type is judged according to the acquiring and processing option instruction, when the transaction type is qPBOC transaction, the transaction type identifier is set as a first type identifier, the smart card acquires the transaction amount from the acquiring and processing option instruction, whether the transaction amount is legal is judged, and if yes, the step s6 is executed; otherwise, reporting an error to the financial terminal, and returning to the step s 1; when the transaction type is the qPBOC expanded transaction, setting the transaction type identifier as a second type identifier, acquiring the transaction amount from the acquisition processing option instruction by the smart card, judging whether the transaction amount is legal, and if so, executing a step s 6; otherwise, reporting an error to the financial terminal, and returning to the step s 1; when the transaction type is a debit and credit transaction, setting the transaction type identifier as a third type identifier, returning an application initialization response to the financial terminal, and returning to the step s 1; when the smart card receives a second load instruction, the smart card obtains the transaction amount from the load instruction, judges whether the transaction amount is legal, and if so, executes step s 6; otherwise, reporting an error to the financial terminal, and returning to the step s 1; when the smart card receives the record reading instruction, detecting a transaction type identifier, and when the transaction type identifier is a first type identifier or a second type identifier, executing step s 7; when the transaction type identifier is a third type identifier, returning a read record response to the financial terminal, and returning to the step s 1;
the step s6 is specifically as follows: if the transaction type is qPBOC transaction or qPBOC expanded transaction, when the smart card judges whether the transaction amount is legal, the smart card calculates the difference between the electronic cash balance and the transaction amount, takes the difference as the current electronic cash balance, returns an application initialization response to the financial terminal, and returns to step s 1; if the transaction type is a debit/credit transaction, and after the smart card judges whether the transaction amount is legal, the smart card takes the transaction amount as the current electronic cash balance, and step s7 is executed;
said step s1 further comprises: when the smart card receives the read extended application record instruction from the financial terminal, returning a read extended application record response to the financial terminal, and returning to the step s 1; when the smart card receives the instruction for updating the extended application record, returning an update extended application record response to the financial terminal, and returning to the step s 1; after receiving the first generated application ciphertext instruction, the smart card returns a first generated application ciphertext response to the financial terminal, and returns to the step s 1; and when the smart card receives the second application ciphertext generating instruction, returning a second application ciphertext generating response to the financial terminal, and returning to the step s 1.
13. A smart card, comprising: the system comprises a first receiving module, a second receiving module, a first detecting module, a first judging module, a first error reporting module, a first updating module, a first application module, a first returning module, a first calculating module, a first transaction module, a first setting module, a second updating module and a second returning module;
the first receiving module is used for receiving an application selection instruction from the financial terminal;
the second receiving module is used for receiving an application transaction instruction from the financial terminal;
the first detection module is configured to detect whether an M1 transaction status flag of the first reception module is set after the first reception module receives the application selection instruction;
the first judging module is used for judging the relationship among the balance of the M1, the balance of the electronic purse and the balance of the electronic cash when the first detecting module detects that the balance is negative;
the first updating module is configured to update the balance of the electronic wallet to the M1 balance when the first determining module determines that the balance of the M1 is minimum; updating the electronic cash balance to the M1 balance;
the first application module is configured to, when the first determining module determines that the M1 balance, the electronic wallet balance, and the electronic cash balance are equal to each other, and the first updating module updates the electronic wallet balance and the electronic cash balance, select an application according to the application selection instruction;
the first error reporting module is configured to report an error to the financial terminal when the first determining module determines that the balance of the M1 is greater than the balance of the electronic wallet or the balance of the electronic cash;
the first returning module is used for returning an application selection success response to the financial terminal after the first application module selects the application according to the application selection instruction;
the first calculation module is used for calculating the balance of the current account according to the transaction amount in the application transaction instruction; the current account balance is the current electronic wallet balance or the current electronic cash balance;
the first setting module is used for setting the M1 transaction status flag after the first calculation module calculates the current account balance; resetting the M1 transaction status flag when the first transaction module closes a transaction;
the first transaction module is used for starting a transaction after the first calculation module calculates the balance of the current account; when the second updating module respectively updates the M1 balance, the electronic wallet balance and the electronic cash balance into the current account balance, closing the transaction;
the second updating module is configured to update the M1 balance, the electronic wallet balance, and the electronic cash balance to the current account balance respectively after the first transaction module starts a transaction;
the second returning module is configured to return a transaction success response to the financial terminal after the second updating module updates the M1 balance, the electronic wallet balance, and the electronic cash balance to the current account balance, respectively;
the intelligent card also comprises a third receiving module, a second detection module, a second calculation module, a third updating module, a second error reporting module and a third returning module;
the third receiving module is used for receiving an M1 consumption instruction from an M1 terminal;
the second detecting module is configured to detect whether an M1 transaction status flag of the third receiving module is set after the third receiving module receives the M1 consumption instruction;
the second error reporting module is configured to report an error to the M1 terminal after the second detection module detects that the second detection module is yes;
the second calculation module is configured to calculate a current M1 balance after the second detection module detects no;
the third updating module is configured to update the M1 balance to a current M1 balance;
the third returning module is used for returning the consumption success information to the M1 terminal;
the second calculating module is specifically configured to, after the second detecting module detects that the M1 balance is not found, obtain an M1 transaction amount from an M1 storage area, obtain an M1 transaction amount from an M1 consumption instruction, calculate a difference between the M1 balance and the M1 transaction amount, and use the difference between the M1 balance and the M1 transaction amount as a current M1 balance;
the third updating module is specifically configured to write the current M1 balance as an M1 balance into an M1 storage area.
14. The smart card of claim 13, wherein the first determining module comprises: the device comprises a first acquisition unit, a second acquisition unit, a third acquisition unit and a first judgment unit;
the first obtaining unit is used for obtaining the M1 balance from an M1 storage area after the first detection module detects no;
the second acquisition unit is used for acquiring the balance of the electronic wallet from a first nonvolatile storage area after the first detection module detects no;
the third obtaining unit is used for obtaining the electronic cash balance from a second nonvolatile storage area after the first detection module detects no;
the first judging unit is used for judging whether the balance of the M1 is larger than the balance of the electronic wallet or the balance of the electronic cash.
15. The smart card of claim 14, wherein the first obtaining unit comprises: the system comprises a first acquisition subunit, a first judgment subunit, a second acquisition subunit, a third acquisition subunit, a second judgment subunit and a fourth acquisition subunit;
the first acquiring subunit is configured to acquire an address of the M1 wallet copy in the M1 storage area and acquire an M1 wallet copy according to the address of the M1 wallet copy after the first detecting module detects no;
the first judging subunit is configured to judge whether the M1 wallet copy is legal;
the second acquiring subunit is configured to acquire the balance of the M1 from the copy of the M1 wallet, when the first determining subunit determines that the balance of the M1 is negative;
the third acquiring subunit is configured to acquire the M1 wallet original address in the M1 storage area, after the first judging subunit judges no; acquiring an M1 wallet master according to the M1 wallet master address;
the second judging subunit is configured to judge whether the M1 wallet master is legal;
the fourth obtaining subunit is configured to, after the second determining subunit determines that the balance is M1, obtain the balance from the M1 wallet body;
and the first application module is further configured to select an application according to the application selection instruction after the second judgment subunit judges that the application is not selected.
16. The smart card of claim 15, further comprising a first recovery module;
the first recovery module is configured to, after the second determination subunit determines that the wallet copy address is the M1 wallet copy address, write the M1 wallet original as the M1 wallet copy address before the first determination module determines the relationship between the M1 balance, the electronic wallet balance, and the electronic cash balance.
17. The smart card of claim 13, wherein the first update module is specifically configured to: when the first judgment module judges that the balance of the M1 is minimum, writing the balance of the M1 into a first nonvolatile storage area as the balance of the electronic wallet; writing the M1 balance as an electronic cash balance into a second non-volatile storage area;
the second updating module is specifically configured to, after the first transaction module starts a transaction, write the current balance of the electronic wallet into an M1 storage area as an M1 balance when the current account balance is the current balance of the electronic wallet; writing the current balance of the electronic wallet into a first nonvolatile storage area as the balance of the electronic wallet; writing the current e-wallet balance as an electronic cash balance into a second non-volatile storage area;
when the current account balance is the current electronic cash balance, writing the current electronic cash balance as an M1 balance into an M1 storage area; writing the current electronic cash balance into a first nonvolatile storage area as an electronic wallet balance; writing the current electronic cash balance as an electronic cash balance into a second non-volatile storage area.
18. The smart card of claim 13, further comprising: a second judgment module;
the second judgment module is used for judging whether the transaction amount in the application transaction instruction is legal or not;
the first calculating module is specifically configured to calculate, when the second determining module determines that the current account balance is the current account balance, a current account balance according to the transaction amount in the application transaction instruction;
the first error reporting module is further configured to report an error to the financial terminal after the second determining module determines that the error is not detected.
19. The smart card of claim 18, wherein the application transaction instructions comprise: an electronic wallet consumption instruction or an electronic wallet earmark instruction or an electronic cash consumption instruction or an electronic cash earmark instruction;
the second judgment module is specifically configured to: when the application transaction instruction is the electronic wallet consumption instruction, judging whether the transaction amount is not larger than the result of adding the overdraft limit to the balance of the electronic wallet and then subtracting the overdraft amount, and if so, judging that the transaction amount is legal; otherwise, judging that the transaction amount is illegal; when the application transaction instruction is the electronic wallet loading instruction, judging whether the transaction amount is not larger than a result of subtracting the sum of the balance of the electronic wallet from the balance of the electronic wallet, adding the overdrawn amount and subtracting the offline pre-authorized total amount, and if so, judging that the transaction amount is legal; otherwise, judging that the transaction amount is illegal;
when the application transaction instruction is the electronic cash consumption instruction, judging whether the transaction amount is not larger than the result of adding the overdraft limit to the electronic cash balance and then subtracting the overdraft amount, and if so, judging that the transaction amount is legal; otherwise, judging that the transaction amount is illegal;
when the application transaction instruction is the electronic cash load instruction, judging whether the transaction amount is not larger than a result of adding the balance upper limit to the overdrawn amount and subtracting the offline pre-authorized total amount, and if so, judging that the transaction amount is legal; otherwise, judging that the transaction amount is illegal.
20. The smart card of claim 18, wherein the application transaction instructions comprise: an electronic wallet consumption instruction or an electronic wallet earmark instruction or an electronic cash consumption instruction or an electronic cash earmark instruction;
the second judgment module is specifically configured to: when the application transaction instruction is the electronic wallet consumption instruction, judging whether the transaction amount is not larger than the balance of the electronic wallet, and if so, judging that the transaction amount is legal; otherwise, judging that the transaction amount is illegal;
when the application transaction instruction is the electronic wallet loading instruction, judging whether the transaction amount is not larger than a result of subtracting the electronic wallet balance from the balance upper limit and subtracting the offline pre-authorization total amount, and if so, judging that the transaction amount is legal; otherwise, judging that the transaction amount is illegal;
when the application transaction instruction is the electronic cash consumption instruction, judging whether the transaction amount is not greater than the balance of the electronic cash, and if so, judging that the transaction amount is legal; otherwise, judging that the transaction amount is illegal;
when the application transaction instruction is the electronic cash load instruction, judging whether the transaction amount is not larger than a result obtained by subtracting the offline pre-authorized total amount from the upper limit of the balance, and if so, judging that the transaction amount is legal; otherwise, judging that the transaction amount is illegal.
21. The smart card of claim 13, wherein the application transaction instructions comprise: an electronic wallet consumption instruction or an electronic wallet loading instruction;
the first calculating module is specifically configured to calculate a difference between the balance of the electronic wallet and the transaction amount when the application transaction instruction is the electronic wallet consumption instruction, and use the difference as the current balance of the electronic wallet;
and when the application transaction instruction is specifically the electronic wallet load instruction, calculating the sum of the balance of the electronic wallet and the transaction amount, and taking the sum as the current balance of the electronic wallet.
22. The smart card of claim 21, further comprising: the device comprises a first acquisition module and a third judgment module;
the electronic wallet consumption instructions comprise: a consumption initialization instruction and a consumption instruction; or specifically comprises a composite consumption initialization instruction, a composite application data cache updating instruction and a composite application consumption instruction; the electronic wallet earmark instruction specifically comprises the following steps: a load initialization instruction and a first load instruction;
the second receiving module includes: a first receiving unit, a second receiving unit, a third receiving unit, a fourth receiving unit, a fifth receiving unit, a sixth receiving unit and a seventh receiving unit;
the second return module includes: a first return unit, a second return unit, and a third return unit;
the first receiving unit is used for receiving the consumption initialization instruction from the financial terminal;
the second receiving unit is used for receiving the consumption instruction from the financial terminal;
the third receiving unit is used for receiving the composite consumption initialization instruction from the financial terminal;
the fourth receiving unit is used for receiving the composite application consumption instruction from the financial terminal;
the fifth receiving unit is used for receiving the load initialization instruction from the financial terminal;
the sixth receiving unit is used for receiving a first credit worthiness instruction from the financial terminal;
the first obtaining module is used for obtaining the transaction amount from the consumption initialization instruction after the first receiving unit receives the consumption initialization instruction; when the third receiving unit receives the composite consumption initialization instruction, the transaction amount is obtained from the composite consumption initialization instruction; when the fifth receiving unit receives the load initialization instruction from the financial terminal, the transaction amount is obtained from the load initialization instruction;
the third judging module is used for judging whether the transaction amount acquired by the first acquiring module is legal or not;
the first returning unit is used for returning an initialization success response to the financial terminal after the third judging module judges that the first judging module is positive;
the first error reporting module is further configured to report an error to the financial terminal after the third determining module determines that the error is not reported;
the first calculating module is specifically configured to calculate a difference between the balance of the electronic wallet and the transaction amount after the second receiving unit receives the consumption instruction or after the fourth receiving unit receives the composite application consumption instruction, and use the difference as the current balance of the electronic wallet; when the sixth receiving unit receives the first credit balance instruction, calculating the sum of the balance of the electronic purse and the transaction amount, and taking the sum as the balance of the current electronic purse;
the second returning unit is used for returning a successful transaction response to the financial terminal after the first transaction module closes the transaction;
the seventh receiving unit is configured to receive the updated composite application data caching instruction from the financial terminal;
and the third returning unit is used for returning an updating success response to the financial terminal after the composite consumption record is updated.
23. The smart card of claim 13, wherein the application transaction instructions comprise: an electronic cash consumption instruction or the electronic cash loading instruction;
the first calculation module is specifically configured to calculate a difference between the electronic cash balance and the transaction amount when the application transaction instruction is specifically the electronic cash consumption instruction, and use the difference as the current electronic cash balance; and when the application transaction instruction is specifically the electronic cash load instruction, taking the transaction amount as the current electronic cash balance.
24. The smart card of claim 23, further comprising: the device comprises a fourth judging module, a second setting module, a second obtaining module, a fifth judging module and a third detecting module; the electronic cash consumption instruction specifically comprises: acquiring a processing option instruction and a reading record instruction; or specifically comprises the following steps: reading an extended application recording instruction, acquiring a processing option instruction, updating the extended application recording instruction and reading the recording instruction; the electronic cash loading instruction specifically comprises the following steps: acquiring a processing option instruction, a reading recording instruction, a first application ciphertext generation instruction, a second application ciphertext generation instruction and a second load instruction;
the second receiving module includes: an eighth receiving unit, a ninth receiving unit, a tenth receiving unit, an eleventh receiving unit, a twelfth receiving unit, a thirteenth receiving unit, and a fourteenth receiving unit;
the second return module: the system comprises a fourth return unit, a fifth return unit, a sixth return unit, a seventh return unit, an eighth return unit, a ninth return unit and a tenth return unit;
the eighth receiving unit is configured to receive the acquiring processing option instruction from the financial terminal;
the ninth receiving unit is used for receiving a reading record instruction from the financial terminal;
the tenth receiving unit is used for receiving a second load instruction from the financial terminal;
the fourth judging module is used for judging the transaction type according to the acquisition processing option instruction;
the second setting module is configured to set the transaction type identifier as the first type identifier when the fourth determining module determines that the transaction type is the qPBOC transaction; when the fourth judging module judges that the transaction type is the qPBOC extended transaction, setting the transaction type identifier as a second type identifier; setting the transaction type identifier as a third type identifier when the transaction type is a debit and credit transaction;
the second obtaining module is configured to obtain a transaction amount from the obtaining processing option instruction when the fourth determining module determines that the transaction type is the qPBOC transaction or the qPBOC expanded transaction; when the fourth judging module judges that the transaction type is a debit and credit transaction, acquiring the transaction amount from the second load instruction;
the fifth judging module is configured to judge whether the transaction amount acquired by the second acquiring module is legal or not;
the first computing unit is specifically configured to, if the transaction type is a qPBOC transaction or a qPBOC expanded transaction, if the fifth determination module determines that the transaction type is a qPBOC expanded transaction: calculating the difference between the electronic cash balance and the transaction amount, and taking the difference as the current electronic cash balance; if the transaction type is a debit and credit transaction, taking the transaction amount as the balance of the current electronic cash after the fifth judgment module judges that the transaction type is the debit and credit transaction;
the fourth returning unit is configured to return an application initialization response to the financial terminal after the fourth determining module determines that the transaction type is a debit/credit transaction; when the fourth judging module judges that the transaction type is qPBOC transaction or qPBOC expanded transaction, the first calculating unit calculates the difference between the electronic cash balance and the transaction amount, and the difference is used as the current electronic cash balance, and then an application initialization response is returned to the financial terminal;
the first error reporting module is further configured to report an error to the financial terminal after the fifth determining module determines that the financial terminal is not the financial terminal;
the third detection module is configured to detect a transaction type identifier after the ninth receiving unit receives the record reading instruction;
the second updating module is specifically configured to update the M1 balance, the electronic wallet balance, and the electronic cash balance to the current electronic cash balance respectively after the third detecting module detects that the transaction type identifier is the first type identifier or the second type identifier; when the first calculation unit takes the transaction amount as a current electronic cash balance, respectively updating the M1 balance, the electronic wallet balance and the electronic cash balance to the current electronic cash balance;
the fifth returning unit is configured to return a read record response to the financial terminal after the third detecting module detects that the transaction type identifier is the third type identifier; when the third detection module detects that the transaction type identifier is the first type identifier or the second type identifier, and when the first setting module resets the M1 transaction state flag, a read record response is returned to the financial terminal;
the sixth returning unit is configured to return a load response to the financial terminal after the tenth receiving unit receives the second load instruction;
the eleventh receiving unit is used for receiving a read extended application record instruction from the financial terminal;
the seventh returning unit is configured to return a read extended application record response to the financial terminal;
the twelfth receiving unit is configured to receive the update extended application record instruction from the financial terminal;
the eighth returning unit is configured to return an update extended application record response to the financial terminal after the update extended application record;
the thirteenth receiving unit is configured to receive the first generated application cryptogram instruction from the financial terminal;
the ninth returning unit is used for returning a first generated application ciphertext response to the financial terminal;
the fourteenth receiving unit is configured to receive the second application cryptogram generation instruction from the financial terminal;
and the tenth returning unit is used for returning a second generated application ciphertext response to the financial terminal.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611042232.9A CN106779635B (en) | 2016-11-22 | 2016-11-22 | Smart card and method for sharing balance of multiple accounts in smart card |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN201611042232.9A CN106779635B (en) | 2016-11-22 | 2016-11-22 | Smart card and method for sharing balance of multiple accounts in smart card |
Publications (2)
Publication Number | Publication Date |
---|---|
CN106779635A CN106779635A (en) | 2017-05-31 |
CN106779635B true CN106779635B (en) | 2020-10-13 |
Family
ID=58974682
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN201611042232.9A Active CN106779635B (en) | 2016-11-22 | 2016-11-22 | Smart card and method for sharing balance of multiple accounts in smart card |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN106779635B (en) |
Families Citing this family (3)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN109064316B (en) * | 2018-08-06 | 2020-10-13 | 飞天诚信科技股份有限公司 | Method and device for recovering offline consumption limit by credit card |
CN110310113B (en) * | 2019-05-20 | 2022-01-04 | 深圳市微付充科技有限公司 | Virtual card matching method based on geographic position, server and mobile terminal |
CN111126986B (en) * | 2019-11-25 | 2023-06-30 | 泰康保险集团股份有限公司 | Data processing method and device based on electronic wallet |
Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN101799954A (en) * | 2009-11-20 | 2010-08-11 | 北京飞天诚信科技有限公司 | Method for loading double electronic purses |
US20120209733A1 (en) * | 2007-10-19 | 2012-08-16 | Ebay Inc. | Unified identity verification |
CN103236003A (en) * | 2013-04-09 | 2013-08-07 | 深圳市雄帝科技股份有限公司 | E-wallet payment method and device |
CN105427098A (en) * | 2015-11-02 | 2016-03-23 | 飞天诚信科技股份有限公司 | Method and device for realizing information sharing among different applications |
-
2016
- 2016-11-22 CN CN201611042232.9A patent/CN106779635B/en active Active
Patent Citations (4)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
US20120209733A1 (en) * | 2007-10-19 | 2012-08-16 | Ebay Inc. | Unified identity verification |
CN101799954A (en) * | 2009-11-20 | 2010-08-11 | 北京飞天诚信科技有限公司 | Method for loading double electronic purses |
CN103236003A (en) * | 2013-04-09 | 2013-08-07 | 深圳市雄帝科技股份有限公司 | E-wallet payment method and device |
CN105427098A (en) * | 2015-11-02 | 2016-03-23 | 飞天诚信科技股份有限公司 | Method and device for realizing information sharing among different applications |
Also Published As
Publication number | Publication date |
---|---|
CN106779635A (en) | 2017-05-31 |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CA2907096C (en) | System and method for using multiple payment accounts using a single payment device | |
CN101799954B (en) | Method for loading double electronic purses | |
CN102044114B (en) | Method for consuming electronic wallet | |
EP3528221A1 (en) | Ic card-based transaction processing and credit payment authorization method, device and system | |
US11087371B2 (en) | Blockchain-based invoice creation method apparatus, and electronic device | |
CN103794000B (en) | Method for processing in case of non-contact IC card data reading failure and device for implementing method | |
US9378498B2 (en) | Method for loading double e-wallets | |
CN106779635B (en) | Smart card and method for sharing balance of multiple accounts in smart card | |
CN101197006B (en) | Smart card and data write-in method | |
US12086801B2 (en) | System and method of using localized blockchain to enable payment card use without connectivity | |
CN104867009A (en) | Intelligent card, quota control system thereof, and quota control method thereof | |
US20230046119A1 (en) | Method for implementing middleware based on emv and terminal device | |
CN108153795A (en) | A kind of data processing method, system and the device of electronics red packet | |
CN101799955A (en) | Method for operating double electronic purses | |
CN105354190A (en) | Numerical information transfer method and apparatus | |
CN102592358A (en) | Method, system and device for writing electronic data | |
US20220398565A1 (en) | Type 4 nfc tags as protocol interface | |
CN108229942B (en) | Recharging method, device and system for electronic wallet | |
CN109064316B (en) | Method and device for recovering offline consumption limit by credit card | |
CN106855976B (en) | Encrypted memory card with recovery mechanism and working method thereof | |
KR20170048358A (en) | System and method for detecting and alerting risks in refill transactions | |
CN111091379B (en) | Method and system for realizing segmented operation of smart card | |
JP5228827B2 (en) | IC card payment terminal | |
KR20240162231A (en) | Method and apparatus for preventing voice phishing using virtual account | |
CN116109304A (en) | Credit card medium data processing method and device based on scenerization business system |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination | ||
GR01 | Patent grant | ||
GR01 | Patent grant |