A method and device for solving transaction failure caused by non-contact field interference

CN122596936APending Publication Date: 2026-08-18FEITIAN TECHNOLOGIES CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202611015410.2
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-07-09
Publication Date
2026-08-18

AI Technical Summary

Technical Problem

[0005]本申请针对现有技术的缺陷,提供了一种解决非接场干扰导致交易失败的方法及装置

Benefits of technology

[0011] The technical solution provided in this application solves the problem of transaction failure caused by non-contact interference with magnetic stripe cards through software. It is applicable to the multi-mode compatible design of payment terminals, avoids hardware modifications to the terminal, and can save the cost of hardware modifications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122596936A_ABST
    Figure CN122596936A_ABST
Patent Text Reader

Abstract

This application relates to the field of information technology, and in particular to a method and apparatus for resolving transaction failures caused by contactless interference. The method includes: enabling contactless and magnetic stripe card detection interrupts on the terminal; if a card-waving action is detected, executing a contactless transaction; monitoring whether the card has been moved during execution; if so, determining whether a magnetic stripe card detection interrupt has been triggered; if so, retrieving raw magnetic stripe data from the magnetic stripe raw data buffer, decoding to obtain magnetic stripe card information, and executing a card-swiping transaction based on the magnetic stripe card information; the method further includes: when the magnetic stripe card enters the terminal's card reader, the terminal collects and stores the raw magnetic stripe data, triggers a magnetic stripe card detection interrupt, the terminal jumps to an interrupt service routine, records the length of the raw magnetic stripe data and the index of the raw magnetic stripe data buffer, and indicates that the magnetic stripe card detection interrupt has been triggered. This application solves the problem of transaction failures caused by contactless interference with magnetic stripe cards through software, avoiding hardware modifications to the terminal and saving hardware modification costs.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This application relates to the field of information technology, and in particular to a method and apparatus for resolving transaction failures caused by non-field interference. Background Technology

[0002] To adapt to different payment scenarios, payment terminals typically need to support magnetic stripe cards, contact IC cards, and contactless (NFC) payment functions simultaneously. Magnetic stripe card payments rely on a physical swipe action, using a magnetic head to read the magnetic stripe information. Contactless payments, on the other hand, are based on Near Field Communication (NFC) technology, using a contactless induction coil to sense the contactless IC card at close range to complete the transaction. In existing technologies, some payment terminals (such as smart POS terminals) are limited by hardware layout, resulting in the contactless induction coil being too close to the magnetic head. When a user uses a magnetic stripe / chip hybrid card (three-in-one card) or a dual-interface magnetic stripe hybrid card, the terminal may prioritize triggering the contactless sensing process and executing the contactless transaction. If the user swipes the card quickly, the card may leave the sensing area of ​​the contactless induction coil before the complete contactless transaction process is finished, ultimately causing both the magnetic stripe card swipe and the contactless transaction to fail.

[0003] Existing solutions to the above problems mostly require hardware modifications to the terminal. However, hardware modifications are costly and may also affect the original performance of the terminal.

[0004] Therefore, how to solve the problem of transaction failure caused by non-field interference with magnetic stripe cards through software has become an urgent technical issue. Summary of the Invention

[0005] This application addresses the shortcomings of existing technologies by providing a method and apparatus for resolving transaction failures caused by non-contact interference.

[0006] Firstly, this application provides a method for resolving transaction failures caused by non-contact interference, including: The terminal enables contactless and magnetic stripe card detection interrupts to detect card movement. If a card-tap action is detected, a contactless transaction is executed. If card removal is detected during the process, it is determined whether the magnetic stripe card detection interrupt has been triggered. If so, the original magnetic stripe data length and the original magnetic stripe data buffer index are obtained. The original magnetic stripe data is retrieved from the original magnetic stripe data buffer based on the original magnetic stripe data length and the original magnetic stripe data buffer index. The original magnetic stripe data is decoded to obtain the magnetic stripe card information, and a card swipe transaction is executed based on the magnetic stripe card information. Otherwise, the transaction fails, and error handling is performed. If no card removal is detected, the contactless transaction is completed. If a card swipe action is detected, a card swipe transaction is executed. When a magnetic stripe card enters the terminal's card reader, the terminal collects the original data of the magnetic stripe track and stores it in the original data buffer of the magnetic stripe track. This triggers a magnetic stripe card detection interrupt, jumps to the magnetic stripe card interrupt service routine, records the length of the original data of the magnetic stripe track and the index of the original data buffer of the magnetic stripe track into a global variable, and indicates that the magnetic stripe card detection interrupt has been triggered.

[0007] Secondly, this application also provides an apparatus for resolving transaction failures caused by non-contact interference, comprising: The startup module is used to enable contactless connection on the terminal and to enable magnetic stripe card detection interrupt. The detection module is used by the terminal to detect card actions. If a card waving action is detected, the first execution module is triggered; if a card swiping action is detected, the third execution module is triggered. The first execution module is used for the terminal to execute contactless transactions. If the card is detected to be moved during the execution process, the judgment module is triggered; otherwise, the contactless transaction is completed. The judgment module is used by the terminal to determine whether the magnetic stripe card detection interrupt has been triggered. If so, the second execution module is triggered; otherwise, the transaction fails and error handling is performed. The second execution module is used for the terminal to obtain the original data length of the magnetic stripe and the index of the original data buffer of the magnetic stripe, to obtain the original data of the magnetic stripe from the original data buffer of the magnetic stripe according to the original data length of the magnetic stripe and the index of the original data buffer of the magnetic stripe, to decode the original data of the magnetic stripe to obtain magnetic stripe card information, and to execute a card swipe transaction according to the magnetic stripe card information; The third execution module is used by the terminal to execute card swiping transactions; The interrupt handling module is used to collect the original data of the magnetic stripe card and store it in the original data buffer of the magnetic stripe card when the magnetic stripe card enters the terminal card reader, trigger the magnetic stripe card detection interrupt, jump to the magnetic stripe card interrupt service routine, record the length of the original data of the magnetic stripe card and the index of the original data buffer of the magnetic stripe card into a global variable, and indicate that the magnetic stripe card detection interrupt has been triggered.

[0008] Thirdly, this application also provides an electronic device. This device can be a device capable of independent operation or a device operating within other devices. The device possesses some or all of the functions of the method described in the first aspect. These functions can be implemented in hardware or by hardware executing corresponding software. The hardware or software includes one or more units or modules corresponding to the aforementioned functions.

[0009] In one embodiment, the electronic device includes a processor and a memory. The processor executes the method provided in the first aspect by calling a computer program stored in the memory. The devices can be disposed on different chips or integrated on the same chip; this application does not limit the specific implementation of the devices.

[0010] Fourthly, this application also provides a chip system that can be deployed in an electronic device. The chip system includes a processor and an interface, the processor being used to implement the methods described in the first aspect above through the interface. The chip system can be composed of chips, or it can include chips and other discrete devices.

[0011] The technical solution provided in this application solves the problem of transaction failure caused by non-contact interference with magnetic stripe cards through software. It is applicable to the multi-mode compatible design of payment terminals, avoids hardware modifications to the terminal, and can save the cost of hardware modifications. Attached Figure Description

[0012] Various other advantages and benefits will become apparent to those skilled in the art upon reading the following detailed description of specific embodiments. The accompanying drawings are for illustrative purposes only and are not intended to limit the embodiments of the invention. Furthermore, throughout the drawings, the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions. In the drawings: Figure 1 A flowchart illustrating a method for resolving transaction failures caused by non-contact interference, provided in Embodiment 1 of this application; Figure 2 This is a flowchart illustrating a method for resolving transaction failures caused by non-contact interference, as provided in Embodiment 2 of this application. Detailed Implementation

[0013] This application proposes a method and apparatus for resolving transaction failures caused by non-contact interference. The embodiments of this application are further described in detail below with reference to the accompanying drawings. The described embodiments are exemplary and are only used to explain this application, and should not be construed as limiting this application.

[0014] Those skilled in the art will understand that, unless specifically stated otherwise, the singular forms “a,” “an,” “the,” and “the” used herein may also include the plural forms. It should be further understood that the term “comprising” as used in this application means the presence of the stated features, integers, steps, operations, elements, and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components, and / or groups thereof. It should be understood that when we say an element is “connected” or “coupled” to another element, it can be directly connected or coupled to the other element, or there may be intermediate elements. Furthermore, “connected” or “coupled” as used herein can include wireless connections or wireless coupling. The term “and / or” as used herein includes all or any units and all combinations of one or more associated listed items.

[0015] Those skilled in the art will understand that, unless otherwise defined, all terms used herein (including technical and scientific terms) have the same meaning as commonly understood by one of ordinary skill in the art to which this application pertains. It should also be understood that terms such as those defined in general dictionaries should be understood to have the same meaning as in the context of the prior art, and should not be interpreted in an idealized or overly formal sense unless specifically defined as herein.

[0016] The embodiments of this application can be combined with each other, and the same or similar concepts or processes may not be described again in some embodiments. Example 1

[0017] This embodiment provides a method for resolving transaction failures caused by contactless interference, applicable to payment terminals that simultaneously support magnetic stripe card payment and contactless payment functions. The terminal includes at least: a magnetic head, a contactless induction coil, an NFC chip (preferably an under-display NFC chip), and a main control chip. Figure 1 As shown, the method specifically includes: Step 1: The terminal starts contactless communication and enables magnetic stripe card detection interrupt; Step 2: The terminal detects card movement. If a waving action is detected, proceed to step 3; if a swiping action is detected, proceed to step 6. In some possible implementations, step 2 specifically includes: the terminal determining whether a card action is detected; if a card waving action is detected, then step 3 is executed; if a card swiping action is detected, then step 6 is executed; otherwise, it determines whether the detection has timed out; if so, the process ends; otherwise, the detection continues and step 2 is executed again.

[0018] Step 3: The terminal executes a contactless transaction. If the card is detected to have been moved during the execution process, proceed to step 4; otherwise, the contactless transaction is completed. In some possible implementations, the terminal executes a contactless transaction. If the card is detected to have been removed during the execution process, step 4 is executed. Specifically, the terminal sends a contactless transaction instruction to the card. If the communication with the card times out, step 4 is executed. The contactless transaction instruction specifically includes: an APDU instruction for selecting the near-field payment system environment and obtaining the card application list; an APDU instruction for application selection; an APDU instruction for obtaining processing options; an APDU instruction for reading card records; and an APDU instruction for generating application ciphertext. Furthermore, step 3 may specifically include: Step 3-1: The terminal sends an APDU instruction to the card for selecting the near-field payment system environment and obtaining the card application list. If the terminal receives the first response from the card, it proceeds to step 3-2. If the communication with the card times out, it proceeds to step 4. Step 3-2: The terminal matches the application according to the application list in the first response and sends an APDU instruction for application selection to the card. If a second response is received from the card, step 3-3 is executed. If the communication with the card times out, step 4 is executed. Step 3-3: The terminal sends an APDU instruction to the card to obtain processing options. If a third response is received from the card, step 3-4 is executed. If the communication with the card times out, step 4 is executed. The third response contains the application file locator. Steps 3-4: The terminal sends an APDU instruction to the card to read the card record specified by the application file locator. If a fourth response is received from the card, proceed to steps 3-5. If the communication with the card times out, proceed to step 4. Steps 3-5: The terminal performs offline data authentication. If the authentication is successful, proceed to step 3-6; if the authentication fails, perform error handling. Steps 3-6: The terminal sends an APDU instruction to the card to generate application ciphertext. If the fifth response is received from the card, then steps 3-7 are executed. If the communication with the card times out, then step 4 is executed. The fifth response contains the application ciphertext generated by the card. Steps 3-7: The terminal interacts with the server to complete the contactless transaction.

[0019] Step 4: The terminal determines whether the magnetic stripe card detection interrupt has been triggered. If yes, proceed to step 5; otherwise, the transaction fails and error handling is performed. Step 5: The terminal obtains the original data length and the original data buffer index of the magnetic stripe card, retrieves the original data of the magnetic stripe card from the original data buffer according to the original data length and the original data buffer index, decodes the original data of the magnetic stripe card to obtain the magnetic stripe card information, and executes the card swipe transaction according to the magnetic stripe card information. Step 6: The terminal executes the card swipe transaction; The method further includes: when the magnetic stripe card enters the terminal's card reader, the terminal collects the original data of the magnetic stripe track and stores it in the original data buffer of the magnetic stripe track, triggers a magnetic stripe card detection interrupt, and jumps to the magnetic stripe card interrupt service routine, in which the following operations are performed: Record the length of the original track data and the index of the original track data buffer into a global variable, and indicate that the magnetic stripe card detection interruption has been triggered.

[0020] In some possible implementations, enabling the magnetic stripe detection interrupt includes: resetting the magnetic stripe card detection interrupt flag, initializing the track raw data buffer, track raw data length, and track raw data buffer index; indicating that the magnetic stripe card detection interrupt has been triggered specifically involves: setting the magnetic stripe card detection interrupt flag to valid; determining whether the magnetic stripe card detection interrupt has been triggered specifically involves: determining the state of the magnetic stripe card detection interrupt flag; if it is valid, the magnetic stripe card detection interrupt is triggered; otherwise, the magnetic stripe card detection interrupt is not triggered.

[0021] In some possible implementations, the operations performed in the magnetic stripe card interruption service procedure also include: recording interruption trigger time information; correspondingly, before step 5, the procedure also includes: the terminal obtaining interruption trigger time information, and determining whether the magnetic stripe card detection interruption trigger duration exceeds a preset time based on the interruption trigger time information; if so, the transaction fails and error handling is performed; otherwise, step 5 is executed. Furthermore, recording the interruption trigger time information specifically involves: calculating and recording the expiration time based on the current system tick value plus a preset effective duration; correspondingly, obtaining the interruption trigger time information, and determining whether the magnetic stripe card detection interruption trigger duration exceeds the preset time based on the interruption trigger time information, specifically: obtaining the expiration time, determining whether the current time has exceeded the expiration time, if so, the magnetic stripe card detection interruption trigger duration exceeds the preset time, otherwise the magnetic stripe card detection interruption trigger duration does not exceed the preset time.

[0022] In some possible implementations, the terminal's main control chip includes an application processor and a security processor. Step 1 specifically includes: the application processor sends a card search command to the security processor, and after receiving the card search command, the security processor starts contactless communication and enables the magnetic stripe card detection interrupt; Step 2 specifically includes: the security processor detects card actions; if a waving action is detected, it notifies the application processor that a contactless IC card has been detected and proceeds to step 3; if a swiping action is detected, it notifies the application processor that a magnetic stripe card has been detected and proceeds to step 6. Step 3 specifically includes: the application processor interacts with the card through the security processor to execute a contactless transaction. If the security processor detects that the card has been moved during the execution process, then step 4 is executed. Furthermore, step 3 may specifically include: the application processor sending a contactless transaction instruction to the security processor; the security processor sending the contactless transaction instruction to the card, and if the communication with the card times out, then step 4 is executed; wherein, the contactless transaction instruction specifically includes: an APDU instruction for selecting the near-field payment system environment and obtaining the card application list, an APDU instruction for selecting an application, an APDU instruction for obtaining processing options, an APDU instruction for reading card records, and an APDU instruction for generating application ciphertext.

[0023] Step 4 specifically includes: the security processor determines whether the magnetic stripe card detection interrupt has been triggered. If so, it sends a specified error code to the application processor and executes step 5; otherwise, it sends a corresponding notification to the application processor, and the application processor performs error handling. Step 5 specifically includes: after receiving the specified error code, the application processor obtains the original data length of the magnetic stripe and the index of the original data buffer of the magnetic stripe, obtains the original data of the magnetic stripe from the original data buffer of the magnetic stripe according to the original data length of the magnetic stripe and the index of the original data buffer of the magnetic stripe, decodes the original data of the magnetic stripe to obtain the magnetic stripe card information, and executes the card swipe transaction according to the magnetic stripe card information.

[0024] Furthermore, enabling the magnetic stripe card detection interrupt specifically includes: resetting the magnetic stripe card detection interrupt flag by the security processor, clearing the original data buffer, the original data length field, and the original data buffer index, and registering the card swipe completion callback function; correspondingly, when the card swipe completion callback function is called, the security processor records the original data length and the original data buffer index into global variables to indicate that the magnetic stripe card detection interrupt has been triggered; wherein, the card swipe completion callback function runs in the interrupt context and is called by the terminal hardware when it determines that the card swipe action is completed; Specifically, when a magnetic stripe card enters the terminal's card reader slot, the magnetic stripe generates an analog electrical signal as it passes over the read / write head. This analog electrical signal is preprocessed by the terminal's magnetic stripe processing circuit, sampled and encoded by the magnetic stripe card processing unit, and then forms a digital sample. The terminal's direct memory access controller automatically moves this digital sample to the original data buffer of the magnetic stripe track. When the magnetic stripe card processing unit determines that the card swiping action is complete or that the original data buffer of the magnetic stripe track has reached a threshold condition, it sends an interrupt request to the terminal relay controller, triggering the magnetic stripe card detection interrupt. The interrupt controller responds to the magnetic stripe card detection interrupt by jumping to the magnetic stripe card interrupt service routine and calling the card swiping completion callback function. Example 2

[0025] This embodiment provides a method for resolving transaction failures caused by contactless interference, applied to a payment terminal. The terminal supports at least magnetic stripe card payment and contactless payment functions simultaneously, and can also support contact IC card payment. The terminal includes at least: a magnetic head, a contactless induction coil, an NFC chip (preferably an under-display NFC chip), and a main control chip. Figure 2 As shown, the method specifically includes: Step Y01: The terminal starts contactless communication, enables magnetic stripe card detection interrupt, and begins magnetic stripe card listening and contactless card search. Specifically, after the user enters the transaction amount through the terminal's upper-layer application and confirms the transaction, step Y01 is executed.

[0026] In one possible implementation, the terminal's activation of the magnetic stripe card detection interrupt includes: Reset the magnetic stripe card detection interrupt flag; Initialize the raw data buffer for the track, and initialize the raw data length and index of the raw data buffer for the track. Registration and card swipe completion callback function.

[0027] Step Y02: The terminal determines whether a card-waving action has been detected. If yes, proceed to step Y03; otherwise, proceed to step Y12. Specifically, after the terminal enables contactless communication, it continuously transmits low-power radio frequency signals and enters listening mode; In one possible implementation, the terminal determines whether a card-waving action has been detected by: detecting whether the load modulation signal has changed; if not, no card-waving action has been detected; if so, a communication request is initiated; if a correct response is received from the card, the card-waving action has been detected; otherwise, no card-waving action has been detected.

[0028] Step Y03: The terminal sends a first APDU instruction to the card. The first APDU instruction is used for near-field payment system environment selection and obtaining the card application list. If the first response is received from the card, then step Y04 is executed. If the communication with the card times out, then step Y10 is executed. The first response contains the application list. Step Y04: The terminal matches the application according to the application list in the first response and sends a second APDU instruction to the card. The second APDU instruction is used for application selection. If the second response returned by the card is received, then step Y05 is executed. If the communication with the card times out, then step Y10 is executed. In one possible implementation, after receiving the second response, the terminal determines whether the application selection is successful based on the second response. If successful, step Y05 is executed; otherwise, the application is re-matched according to the application list in the first response, and the second APDU instruction is resent to the card to select the re-matched application until the application selection is successful or there is no matching application in the application list.

[0029] Step Y05: The terminal sends a third APDU instruction to the card. The third APDU instruction is used to obtain processing options. If a third response is received from the card, step Y06 is executed. If the communication with the card times out, step Y10 is executed. The third response contains the application file locator. Step Y06: The terminal sends a fourth APDU instruction to the card. The fourth APDU instruction is used to read the card record specified by the application file locator. If a fourth response is received from the card, step Y07 is executed. If the communication with the card times out, step Y10 is executed. The fourth response contains the record data. In one possible implementation, the application file locator specifies multiple card records. The terminal sends a series of fourth APDU instructions to the card to read them one by one. After all records are read, step Y07 is executed. Step Y07: The terminal performs offline data authentication. If the authentication is successful, proceed to step Y08; otherwise, perform error handling. In one possible implementation, the third response returned by the card also includes application interaction features, and the terminal determines the data authentication method based on the application interaction features. Alternatively, exception handling could involve terminating the transaction or performing combined dynamic data authentication, etc.

[0030] Step Y08: The terminal sends a fifth APDU instruction to the card. The fifth APDU instruction is used to generate application ciphertext. If a fifth response is received from the card, then step Y09 is executed. If the communication with the card times out, then step Y10 is executed. The fifth response contains the application ciphertext generated by the card. Step Y09: The terminal interacts with the server to complete the transaction, closes the contactless connection, and ends. In one possible implementation, the third response returned by the card also includes application interaction features. The terminal determines whether to perform cardholder verification and the verification method based on the application interaction features. If PIN code verification is required, the terminal also obtains the PIN code entered by the cardholder before step Y09. Specifically, the terminal sends a transaction request message to the server based on the data or execution results obtained in the aforementioned steps, receives the transaction results and script data returned by the server, sends the script data to the card for card update, and receives the result data returned by the card.

[0031] Step Y10: The terminal determines whether the magnetic stripe card detection interrupt has been triggered. If yes, proceed to step Y11; otherwise, the transaction fails and error handling is performed. In one possible implementation, error handling specifically involves: outputting a prompt (indicating that the transaction was not completed and / or the type of error); closing contactless access, ending the process, or continuing magnetic stripe card monitoring and contactless card search, and returning to step Y02; Specifically, the terminal determines the status of the magnetic stripe card detection interrupt flag. If it is valid, the magnetic stripe card detection interrupt is triggered; otherwise, the magnetic stripe card detection interrupt is not triggered.

[0032] In one possible implementation, when a magnetic stripe card enters the terminal's card reader, the terminal hardware automatically collects the original magnetic stripe data and stores it in the original magnetic stripe data buffer, triggering a magnetic stripe card detection interrupt. After the terminal detects a magnetic stripe card detection interruption, it saves the current running context, jumps to the magnetic stripe card interrupt service routine, records the original data length of the magnetic stripe track in the magnetic stripe card interrupt service routine, and calls the card swipe completion callback function to perform the following operations: Record the interruption trigger time, record the original data length of the magnetic stripe and the buffer index to a global variable, and set the magnetic stripe card interruption detection flag to valid.

[0033] In one possible real-time method, the operation executed by calling the card swipe completion callback function also includes: recording the interrupt trigger time; correspondingly, before determining that the magnetic stripe card detection interrupt is triggered in step Y10, the method also includes: the terminal determining whether the magnetic stripe card detection interrupt trigger duration exceeds the preset time. If so, the transaction fails and error handling is performed; otherwise, step Y11 is executed. Step Y11: When the magnetic stripe card detection interrupt is triggered, the terminal decodes the raw magnetic stripe data collected by the terminal to obtain the magnetic stripe card information, interacts with the server, completes the transaction, and ends. Step Y12: The terminal determines whether a card swipe action has been detected. If yes, proceed to step Y13; otherwise, proceed to step Y14. Step Y13: The terminal obtains the magnetic stripe card information, interacts with the server, completes the transaction, and ends. Specifically, the terminal determines the status of the magnetic stripe card detection interrupt flag. If it is valid, a card swiping action is detected. The terminal decodes the original magnetic stripe data collected when the magnetic stripe card detection interrupt is triggered to obtain the magnetic stripe card information. Otherwise, no card swiping action is detected.

[0034] Step Y14: The terminal determines whether the detection has timed out. If so, it closes the contactless connection and ends the process; otherwise, it returns to step Y02.

[0035] In this embodiment, the terminal cyclically detects card swiping and card waving actions. The above example takes determining whether card waving is detected first. In another possible implementation, the terminal first determines whether card swiping is detected. If card swiping is not detected, then it determines whether card waving is detected. This will not be elaborated further here.

[0036] Furthermore, if the terminal implementing the method of this embodiment also has a contact IC card slot, that is, the terminal also has contact IC card payment function, before step Y02, it also includes determining whether a card insertion action is detected. If yes, a contact IC card transaction is executed; otherwise, step Y02 is executed. Then, in step Y14, if the determination is no, the process returns to the step of determining whether a card insertion action is detected. Of course, there is no specific order in which the terminal detects card insertion, card swiping, and card tapping actions. Example 3

[0037] This embodiment provides a method for resolving transaction failures caused by contactless interference, applied to a payment terminal. The terminal supports at least magnetic stripe card payment and contactless payment functions simultaneously, and can also support contact IC card payment. The terminal includes at least: a magnetic head, a contactless induction coil, an NFC chip (preferably an under-display NFC chip), and a main control chip. The main control chip includes a security processor (SP) and an application processor (AP). The method specifically includes: Step 1: The application processor sends a card search command to the security processor; Specifically, after the user enters the transaction amount through the terminal's upper-layer application and confirms the transaction, step 1 is executed.

[0038] Step 2: After receiving the card search command, the security processor starts contactless operation, enables magnetic stripe card detection interrupt, and enables magnetic stripe card listening and contactless card search. In one possible implementation, enabling the magnetic stripe card detection interrupt by the security processor includes: resetting the magnetic stripe card detection interrupt flag; clearing the track raw data buffer, the track raw data length field, and the track raw data buffer index; reloading the destination address and transmission count of the direct memory access channel to enable direct memory access transmission; writing the sampling enable flag to the digital signal processor control register; and registering the card swipe completion callback function.

[0039] Step 3: The security processor determines whether a card-waving action has been detected. If yes, proceed to step 4; otherwise, proceed to step 34. Specifically, after the security processor initiates contactless operation, the contactless induction coil continuously emits a carrier signal at a specific frequency (preferably 13.56MHz), forming a stable alternating electromagnetic field, i.e., a radio frequency field. When a contactless IC card conforming to the ISO / IEC 14443 standard enters the radio frequency field range, the card's built-in antenna coil couples electromagnetic energy. This coupled energy powers the card's chip, causing the card to power on and reset, entering the working state. The security processor detects a change in the load modulation signal and sends an initial request to activate the card. The card then sends a predefined response signal to the security processor. Upon receiving a valid card response signal, the security processor confirms the presence of a contactless IC card, i.e., confirms that a card-waving action has been detected.

[0040] Step 4: The security processor notifies the application processor that a contactless IC card has been found; Step 5: After receiving the notification, the application processor sends the first APDU instruction to the security processor. The first APDU instruction is used by the PPSE (Proximity Payment System Environment) to select and obtain the card application list. Step 6: The security processor sends the received first APDU instruction to the card. If it receives the first response from the card, it executes step 7. The first response contains the application list. If the communication with the card times out, it executes step 27. Step 7: The security processor returns the first response to the application processor; Step 8: After the application processor matches the application list according to the transaction kernel, it sends a second APDU instruction to the security processor. The second APDU instruction is used for application selection. Step 9: The security processor sends the received second APDU instruction to the card. If a second response is received from the card, step 10 is executed. The second response contains the application selection result. If the communication with the card times out, step 27 is executed. Step 10: The security processor returns a second response to the application processor; Step 11: The application processor sends a third APDU instruction to the security processor. The third APDU instruction is used to obtain processing options. In one possible implementation, the application processor determines whether the application selection was successful based on the application selection result. If successful, it executes step 11; otherwise, it re-matches the application list, sends a second APDU instruction to the security processor, and executes step 9.

[0041] Step 12: The security processor sends the received third APDU instruction to the card. If a third response is received from the card, then step 13 is executed. The third response contains the AFL (Application File Locator). If the communication with the card times out, then step 27 is executed. Step 13: The security processor returns a third response to the application processor; Step 14: The application processor sends a fourth APDU instruction to the security processor. The fourth APDU instruction is used to read the record specified by the AFL. Step 15: The security processor sends the received fourth APDU instruction to the card. If a fourth response is received from the card, then step 16 is executed. The fourth response contains the recorded data. If the communication with the card times out, then step 27 is executed. Step 16: The security processor returns the fourth response to the application processor; In one possible implementation, the AFL specifies multiple records. The application processor sends the fourth APDU instruction to the security processor one by one. The security processor sends the instructions to the card one by one. The card returns the record data to the security processor one by one. The security processor returns the record data to the application processor one by one. After all the record data is successfully read, step 17 is executed.

[0042] Step 17: The application processor performs Offline Data Authentication (ODA). Specifically, if offline data authentication is successful, proceed to step 18; if offline data authentication fails, the application processor terminates the process and prompts the user to retry or switch to Combined Dynamic Data Authentication (CDA) through the upper-layer application.

[0043] Step 18: The application processor sends a fifth APDU instruction to the security processor. The fifth APDU instruction is used to generate application ciphertext. Step 19: The security processor sends the received fifth APDU instruction to the card. If it receives the fifth response from the card, it executes step 20. The fifth response contains the application ciphertext generated by the card. If the communication with the card times out, it executes step 27. Step 20: The application processor calls the PIN code input function of the security processor to obtain the PIN code entered by the cardholder; Step 21: The application processor sends the transaction-related data to the server and receives the script data returned by the server. In one possible implementation, the transaction-related data includes the transaction amount, transaction type, card record data, PIN code, etc.

[0044] Step 22: The application processor sends the script data to the security processor; Step 23: The security processor sends script data to the card for card update and receives the result data returned by the card. Step 24: The security processor sends the result data returned by the card to the application processor; In one possible implementation, after the security processor sends the script data to the card, a communication timeout occurs, meaning that no response is received from the card within the predetermined time, which does not affect the completion of the transaction.

[0045] Step 25: The application processor sends a shutdown command to the security processor; Step 26: The security processor closes the non-contact connection, ending the process.

[0046] Step 27: The security processor determines whether the magnetic stripe card detection interrupt has been triggered. If yes, proceed to step 28; otherwise, proceed to step 32. Specifically, when a magnetic stripe card enters the terminal's card reader, the magnetic stripe generates an analog electrical signal as it passes over the read / write head. This analog signal is preprocessed by the terminal's magnetic stripe processing circuit and then sent to the magnetic stripe card processing unit. The analog-to-digital converter inside the magnetic stripe card processing unit continuously samples the analog signal at a preset frequency. The built-in digital signal processor automatically identifies peak points generated by flux reversal based on a configured zero-crossing threshold and peak detection algorithm, encoding the peak information into digital samples. During this process, the direct memory access controller automatically moves the digital samples of each track from the magnetic stripe card processing unit to the corresponding memory buffer (i.e., the track's original data buffer) without the intervention of the security processor. Whenever a track accumulates a preset number of samples, the direct memory access interrupt handler updates the destination address and continues the next block transfer until the entire card data is transferred. When the magnetic stripe card processing unit determines that the card swiping is complete (or the buffer reaches the threshold condition), it sets the internal interrupt flag (i.e., the digital signal processor interrupt flag) and sends an interrupt request to the interrupt controller via a dedicated interrupt line, triggering the magnetic stripe card detection interrupt.

[0047] After the interrupt controller responds to the magnetic stripe card detection interrupt, it saves the current running context and jumps to the magnetic stripe card interrupt service routine for execution.

[0048] The magnetic stripe card interrupt service routine performs the following operations in sequence: Step x1: Write a clear operation to the digital signal processor control register of the magnetic stripe card processing unit and reset the digital signal processor interrupt flag bit; Step x2: Disable hardware sampling; Specifically, clear the digital signal processor enable flag to stop continuous sampling of the analog-to-digital converter and peak detection of the digital signal processor; Step x3: Record the original track data length; Specifically, by using the indirect addressing method between the address register and the data register of the digital signal processor, the data count register of each track is read sequentially, and the actual sampling data length of the three tracks is stored in the corresponding position. Step x4: Stop direct memory access transfer; Specifically, disable the direct memory access channel for each track; Step x5: Call the card swipe completion callback function; Specifically, the interrupt callback handling logic transfers processing control to the security processor by calling the card swipe completion callback function.

[0049] The card swipe completion callback function runs in an interrupt context. To avoid blocking interrupts, it only performs a very simple atomic state update and does not perform any data decoding operations, so it has almost no impact on the speed of the contactless process.

[0050] The callback function after the card swipe is completed performs the following operations: Step y1: Record the interrupt trigger time; Specifically, based on the current system tick value, add a preset effective duration (e.g., 2000 milliseconds) to calculate and record the expiration time; Step y2: Record the actual sampled track raw data length and track raw data buffer index of each track into a global variable; Step y3: Set the magnetic stripe card detection interruption flag to a valid state.

[0051] Specifically, in this embodiment, the interrupt flag of the digital signal processor is reset to prevent repeated interrupts due to the flag not being cleared; hardware adoption is disabled to prevent captured magnetic stripe data from being overwritten by subsequent noise or the next card swipe action; direct memory access transmission is stopped to prevent data transfer from going out of bounds or subsequent false triggers; the card swipe event in the current transaction process is distinguished from the historical events left over from the previous one by recording the interrupt trigger time; and the magnetic stripe card detection interrupt flag is set to a valid state to indicate that a card swipe event belonging to the current monitoring period has occurred.

[0052] In this embodiment, the security processor determines whether the magnetic stripe card detection interrupt has been triggered. Specifically, the security processor determines the state of the magnetic stripe card detection interrupt flag. If it is valid, the magnetic stripe card detection interrupt is triggered; otherwise, the magnetic stripe card detection interrupt is not triggered.

[0053] Step 28: The security processor sends a specific error code to the application processor; Step 29: After receiving a specific error code, the application processor determines whether the magnetic stripe card detection interrupt trigger time exceeds the preset time. If so, the transaction fails and ends; otherwise, proceed to step 30. In this embodiment, the application processor determines whether the current time has exceeded the expiration time calculated and recorded by the card swiping completion callback function when the magnetic stripe card detection interrupt is triggered. If so, the magnetic stripe card detection interrupt trigger duration exceeds the preset time; otherwise, the magnetic stripe card detection interrupt trigger duration has not exceeded the preset time.

[0054] Step 30: The application processor obtains the magnetic stripe card information; In this embodiment, when the application processor is triggered by the magnetic stripe card detection interrupt, the card swipe completion callback function retrieves the original sampled data (the sampled data obtained by sampling the pre-processed analog electrical signal generated when the magnetic stripe of the magnetic stripe card passes through the magnetic head) from the actual sampled original data length of each track and the buffer pointer (from the original data buffer of the track) of each track recorded in the global variable. The original sampled data is then decoded to obtain the magnetic stripe card information.

[0055] Step 31: The application processor interacts with the server based on the magnetic stripe card information and transaction data to complete the transaction and end the process.

[0056] Step 32: The security processor notifies the application processor that the contactless IC card has left the site and the transaction cannot be completed. Step 33: After receiving the notification, the application processor performs exception handling.

[0057] For example, the application processor terminates the transaction and sends a shutdown instruction to the security processor. Upon receiving the shutdown instruction, the security processor closes the contactless connection.

[0058] Step 34: The security processor determines whether a card swipe action has been detected. If yes, proceed to step 35; otherwise, proceed to step 38. In this embodiment, the security processor determines the status of the magnetic stripe card detection interrupt flag. If it is valid, a card swiping action is detected; otherwise, no card swiping action is detected.

[0059] Step 35: The security processor notifies the application processor that the magnetic stripe card has been found; Step 36: After receiving the notification, the application processor obtains the magnetic stripe card information; In this embodiment, the process of the application processor obtaining magnetic stripe card information in step 36 is the same as in step 30.

[0060] Step 37: The application processor interacts with the server based on the magnetic stripe card information and transaction data to complete the transaction and end the process.

[0061] Step 38: The security processor determines whether the card search has timed out. If so, proceed to step 39; otherwise, return to step 3. Step 39: The security processor notifies the application processor that the card search has failed. Step 40: After receiving the notification, the application processor performs exception handling. For example, the application processor terminates the transaction and sends a closing instruction to the security processor, which then closes the contactless connection upon receiving the closing instruction; or, the application processor prompts the user to use the card to conduct the transaction through the upper-layer application and returns to step 3. Example 4

[0062] This embodiment provides a device for resolving transaction failures caused by non-contact interference based on the above method. This device is applied to payment terminals that simultaneously support magnetic stripe card payment and contactless payment functions. Specifically, the device includes: The startup module is used to initiate contactless terminal startup and enable magnetic stripe card detection interrupt. The detection module is used by the terminal to detect card actions. If a card waving action is detected, the first execution module is triggered; if a card swiping action is detected, the third execution module is triggered. The first execution module is used for the terminal to execute contactless transactions. If the card is detected to be moved during the execution process, the judgment module is triggered; otherwise, the contactless transaction is completed. The judgment module is used by the terminal to determine whether the magnetic stripe card detection interrupt has been triggered. If it is, the second execution module is triggered; otherwise, the transaction fails and error handling is performed. The second execution module is used to obtain the length of the original magnetic stripe data and the index of the original magnetic stripe data buffer of the terminal, obtain the original magnetic stripe data from the original magnetic stripe data buffer according to the length of the original magnetic stripe data and the index of the original magnetic stripe data buffer, decode the original magnetic stripe data to obtain the magnetic stripe card information, and execute the card swipe transaction according to the magnetic stripe card information; The third execution module is used for the terminal to execute card swipe transactions; The interrupt handling module is used to collect the original magnetic stripe data of the magnetic stripe card and store it in the original magnetic stripe data buffer when the magnetic stripe card enters the terminal card reader. This triggers the magnetic stripe card detection interrupt, jumps to the magnetic stripe card interrupt service routine, records the length of the original magnetic stripe data and the index of the original magnetic stripe data buffer into a global variable, and indicates that the magnetic stripe card detection interrupt has been triggered.

[0063] In some possible implementations, the detection module is specifically used by the terminal to determine whether a card action is detected. If a card waving action is detected, the first execution module is triggered. If a card swiping action is detected, the third execution module is triggered. Otherwise, it is determined whether the detection has timed out. If it has, the detection ends; otherwise, the detection continues and the card action is re-determined.

[0064] In some possible implementations, the first execution module is specifically used to send contactless transaction instructions from the terminal to the card. If the communication with the card times out, the judgment module is triggered; otherwise, the contactless transaction is completed. The contactless transaction instructions specifically include: APDU instructions for selecting the near-field payment system environment and obtaining the card application list; APDU instructions for application selection; APDU instructions for obtaining processing options; APDU instructions for reading card records; and APDU instructions for generating application ciphertext. Furthermore, the first execution module may specifically include: The selection and acquisition unit is used by the terminal to send an APDU instruction to the card for near-field payment system environment selection and to obtain the card application list. If the first response is received from the card, the matching and selection unit is triggered. If the communication with the card times out, the judgment module is triggered. The matching and selection unit is used by the terminal to match applications according to the application list in the first response and send an APDU instruction for application selection to the card. If a second response is received from the card, the processing option acquisition unit is triggered. If the communication with the card times out, the judgment module is triggered. The processing option acquisition unit is used by the terminal to send an APDU instruction to the card to acquire processing options. If a third response is received from the card, the reading unit is triggered. If the communication with the card times out, the judgment module is triggered. The third response contains the application file locator. The reading unit is used by the terminal to send an APDU instruction to the card to read the card record specified by the application file locator. If the terminal receives the fourth response returned by the card, it triggers the authentication unit. If the communication with the card times out, it triggers the judgment module. The authentication unit is used by the terminal to perform offline data authentication. If the authentication is successful, the generation unit is triggered; if the authentication fails, error handling is performed. The generation unit is used by the terminal to send an APDU instruction to the card to generate application ciphertext. If the terminal receives the fifth response returned by the card, it triggers the interaction unit. If the communication with the card times out, it triggers the judgment module. The fifth response contains the application ciphertext generated by the card. The interaction unit is used for interaction between the terminal and the server to complete contactless transactions.

[0065] In some possible implementations, the interrupt handling module is also used to: record interrupt trigger time information; correspondingly, the second execution module is specifically used to: obtain the interrupt trigger time information, determine whether the magnetic stripe card detection interrupt trigger duration exceeds the preset time, if so, the transaction fails and error handling is performed; otherwise, obtain the original data length of the magnetic stripe track and the original data buffer index of the magnetic stripe track, obtain the original data of the magnetic stripe track from the original data buffer according to the original data length of the magnetic stripe track and the original data buffer index of the magnetic stripe track, decode the original data of the magnetic stripe track to obtain the magnetic stripe card information, and perform a card swipe transaction according to the magnetic stripe card information.

[0066] In some possible implementations: The startup module includes: a first startup unit, located in the application processor of the terminal, for sending a card search command to the security processor of the terminal; and a second startup unit, located in the security processor, for starting a contactless connection and enabling the magnetic stripe card detection interrupt after receiving the card search command. The detection module includes: a first detection unit, which is set in the security processor and is used to detect card actions. If a card waving action is detected, the application processor is notified that a contactless IC card has been detected, triggering the first execution module. If a card swiping action is detected, the application processor is notified that a magnetic stripe card has been detected, triggering the third execution module. The first execution module is located in the application processor. Specifically, it is used to interact with the card through the security processor to execute contactless transactions. If the security processor detects that the card has been moved during the execution process, it will trigger the judgment module; otherwise, the contactless transaction will be completed. Furthermore, the first execution module includes: a first execution unit, located in the application processor, for issuing contactless transaction instructions to the security processor; and a second execution unit, located in the security processor, for sending the contactless transaction instructions to the card. If communication with the card times out, a judgment module is triggered; otherwise, the contactless transaction is completed. Specifically, the contactless transaction instructions include: APDU instructions for selecting the near-field payment system environment and obtaining the card application list; APDU instructions for application selection; APDU instructions for obtaining processing options; APDU instructions for reading card records; and APDU instructions for generating application ciphertext. The judgment module includes: a judgment unit, which is set in the security processor, for judging whether the magnetic stripe card detection interrupt is triggered; and a sending unit, which is used to send a specified error code to the application processor when the judgment unit judges that it is yes, triggering the second execution module, and also to send a corresponding notification to the application processor when the judgment unit judges that it is no, so that the application processor can perform error handling. The second execution module is located in the application processor. Specifically, after receiving a specified error code, it obtains the length of the original magnetic stripe data and the index of the original magnetic stripe data buffer. Based on the length of the original magnetic stripe data and the index of the original magnetic stripe data buffer, it retrieves the original magnetic stripe data from the original magnetic stripe data buffer, decodes the original magnetic stripe data to obtain the magnetic stripe card information, and executes a card swipe transaction based on the magnetic stripe card information.

[0067] The relevant content of this embodiment can be found in the above method embodiments, and will not be described in detail here.

[0068] The above-disclosed embodiments are merely a few specific examples of this application. However, this application is not limited thereto, and any variations that can be conceived by those skilled in the art should fall within the protection scope of this application.

[0069] Optionally, this application also provides an electronic device including at least one processor, a memory, and instructions stored in the memory and executable by the at least one processor. The at least one processor executes the instructions to implement the methods described in the above embodiments. Of course, the memory may not be present in the electronic device. The electronic device can be a standalone device or a chip, chip system, or processor that supports the implementation of the above methods. When the electronic device is a chip system, it can be composed of chips or may include chips and other discrete devices; this application does not specifically limit this. The chip is coupled to the memory and is used to execute the computer program stored in the memory to perform the methods described in the above embodiments.

[0070] In the above embodiments, implementation can be achieved, in whole or in part, through software, hardware, firmware, or any combination thereof. When implemented using software programs, implementation can be, in whole or in part, in the form of a computer program product. This computer program product includes one or more computer programs. When the computer program is loaded and executed, it generates, in whole or in part, the processes or functions described in the embodiments of this application. The computer program can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one base station, registration device, server, or data center to another via wired (e.g., coaxial cable, fiber optic, digital subscriber line (DSL)) or wireless (e.g., infrared, wireless, microwave, etc.) means. The computer-readable storage medium can be any available medium accessible to the registration device or a data storage device including one or more servers, data centers, etc., that can be integrated with the medium. The available medium can be a magnetic medium (e.g., floppy disk, hard disk, magnetic tape), an optical medium (e.g., DVD), or a semiconductor medium (e.g., solid-state disk (SSD)).

[0071] Although this application has been described in conjunction with specific features and embodiments, it is obvious that various modifications and combinations can be made thereto without departing from the spirit and scope of this application. Accordingly, this specification and drawings are merely exemplary illustrations of this application as defined by the appended claims, and are considered to cover any and all modifications, variations, combinations, or equivalents within the scope of this application. Clearly, those skilled in the art can make various alterations and modifications to this application without departing from the spirit and scope of this application. Thus, if such modifications and modifications of this application fall within the scope of the claims of this application and their equivalents, this application is also intended to include such modifications and modifications.

Claims

1. A method for resolving transaction failures caused by non-contact interference, characterized in that, include: Step 1: The terminal starts contactless communication and enables magnetic stripe card detection interrupt; Step 2: The terminal detects card actions. If a waving action is detected, proceed to step 3; if a swiping action is detected, proceed to step 6. Step 3: The terminal executes a contactless transaction. If the card is detected to have been moved during the execution process, then step 4 is executed; otherwise, the contactless transaction is completed. Step 4: The terminal determines whether the magnetic stripe card detection interrupt has been triggered. If yes, proceed to step 5; otherwise, the transaction fails and error handling is performed. Step 5: The terminal obtains the original data length of the magnetic stripe and the index of the original data buffer of the magnetic stripe, obtains the original data of the magnetic stripe from the original data buffer of the magnetic stripe according to the original data length of the magnetic stripe and the index of the original data buffer of the magnetic stripe, decodes the original data of the magnetic stripe to obtain the magnetic stripe card information, and performs a card swipe transaction according to the magnetic stripe card information; Step 6: The terminal executes a card swipe transaction; The method further includes: When a magnetic stripe card enters the terminal's card reader, the terminal collects the original data of the magnetic stripe track and stores it in the original data buffer of the magnetic stripe track, triggers the magnetic stripe card detection interrupt, jumps to the magnetic stripe card interrupt service routine, records the length of the original data of the magnetic stripe track and the index of the original data buffer of the magnetic stripe track into a global variable, and identifies that the magnetic stripe card detection interrupt has been triggered.

2. The method for resolving transaction failures caused by non-contact interference as described in claim 1, characterized in that, The activation of the magnetic stripe card detection interrupt includes: resetting the magnetic stripe card detection interrupt flag, initializing the original data buffer of the magnetic stripe track, the original data length of the magnetic stripe track, and the index of the original data buffer of the magnetic stripe track; The specific method for indicating that the magnetic stripe card detection interruption has been triggered is to set the magnetic stripe card detection interruption flag to active. The specific steps for determining whether the magnetic stripe card detection interrupt has been triggered are as follows: determine the state of the magnetic stripe card detection interrupt flag bit. If it is in a valid state, the magnetic stripe card detection interrupt is triggered; otherwise, the magnetic stripe card detection interrupt is not triggered.

3. The method for resolving transaction failures caused by non-contact interference as described in claim 1, characterized in that, The terminal executes a contactless transaction. If the card is detected to be moved during the execution process, step 4 is executed. Specifically, the terminal sends a contactless transaction instruction to the card. If the communication with the card times out, step 4 is executed. The contactless transaction instructions specifically include: APDU instructions for selecting the near-field payment system environment and obtaining the card application list, APDU instructions for application selection, APDU instructions for obtaining processing options, APDU instructions for reading card records, and APDU instructions for generating application ciphertext.

4. The method for resolving transaction failures caused by non-contact interference as described in claim 1, characterized in that, Step 3 specifically includes: Step 3-1: The terminal sends an APDU instruction to the card for selecting the near-field payment system environment and obtaining the card application list. If the terminal receives the first response returned by the card, it executes step 3-2. If the communication with the card times out, it executes step 4. Step 3-2: The terminal matches an application according to the application list in the first response and sends an APDU instruction for application selection to the card. If a second response is received from the card, step 3-3 is executed. If the communication with the card times out, step 4 is executed. Step 3-3: The terminal sends an APDU instruction to the card to obtain processing options. If a third response is received from the card, step 3-4 is executed. If communication with the card times out, step 4 is executed. The third response contains an application file locator. Steps 3-4: The terminal sends an APDU instruction to the card to read the card record specified by the application file locator. If a fourth response is received from the card, steps 3-5 are executed. If communication with the card times out, step 4 is executed. Steps 3-5: The terminal performs offline data authentication. If the authentication is successful, proceed to step 3-6; if the authentication fails, perform error handling. Steps 3-6: The terminal sends an APDU instruction to the card to generate application ciphertext. If a fifth response is received from the card, steps 3-7 are executed. If communication with the card times out, step 4 is executed. The fifth response contains the application ciphertext generated by the card. Steps 3-7: The terminal interacts with the server to complete the contactless transaction.

5. The method for resolving transaction failures caused by non-contact interference as described in claim 1, characterized in that, The method is applied to a terminal that includes an application processor and a security processor; Step 1 specifically includes: the application processor sending a card search command to the security processor; after receiving the card search command, the security processor enables contactless connection and enables magnetic stripe card detection interrupt. Step 2 specifically includes: the security processor detects card actions; if a waving action is detected, it notifies the application processor that a contactless IC card has been detected and executes step 3; if a swiping action is detected, it notifies the application processor that a magnetic stripe card has been detected and executes step 6. Step 3 specifically includes: the application processor interacts with the card through the security processor to execute a contactless transaction; if the security processor detects that the card has been moved during the execution, then step 4 is executed. Step 4 specifically includes: the security processor determines whether the magnetic stripe card detection interrupt is triggered. If yes, it sends a specified error code to the application processor and executes step 5. Otherwise, it sends a corresponding notification to the application processor, and the application processor performs error handling. Step 5 specifically includes: after receiving the specified error code, the application processor obtains the original data length of the magnetic stripe and the original data buffer index of the magnetic stripe, obtains the original data of the magnetic stripe from the original data buffer according to the original data length of the magnetic stripe and the original data buffer index of the magnetic stripe, decodes the original data of the magnetic stripe to obtain the magnetic stripe card information, and performs a card swipe transaction according to the magnetic stripe card information.

6. The method for resolving transaction failures caused by non-contact interference as described in claim 5, characterized in that, The specific steps of enabling the magnetic stripe card detection interrupt include: the security processor resetting the magnetic stripe card detection interrupt flag, clearing the original data buffer of the magnetic stripe track, the original data length field of the magnetic stripe track and the index of the original data buffer of the magnetic stripe track, and registering the card swipe completion callback function. When the card swipe completion callback function is called, the security processor records the original data length of the magnetic stripe and the index of the original data buffer of the magnetic stripe into a global variable, indicating that the magnetic stripe card detection interrupt has been triggered; The card swipe completion callback function runs in an interrupt context and is called by the terminal hardware when it determines that the card swipe action is complete.

7. The method for resolving transaction failures caused by non-contact interference as described in claim 5, characterized in that, Step 3 specifically includes: the application processor sending a contactless transaction instruction to the security processor; the security processor sending the contactless transaction instruction to the card; if the communication with the card times out, then step 4 is executed. The contactless transaction instructions specifically include: APDU instructions for selecting the near-field payment system environment and obtaining the card application list, APDU instructions for application selection, APDU instructions for obtaining processing options, APDU instructions for reading card records, and APDU instructions for generating application ciphertext.

8. The method for resolving transaction failures caused by non-contact interference as described in claim 1, characterized in that, The process of jumping to the magnetic stripe card interrupt service routine also includes: recording the interrupt trigger time information; Before step 5, the process includes: the terminal acquiring the interruption trigger time information, and determining whether the magnetic stripe card detection interruption trigger duration exceeds a preset time based on the interruption trigger time information. If so, the transaction fails and error handling is performed; otherwise, step 5 is executed.

9. The method for resolving transaction failures caused by non-contact interference as described in claim 8, characterized in that, The specific method for recording the interruption trigger time information is as follows: based on the current system tick value, add a preset effective duration, calculate and record the timeout deadline; The step of obtaining the interruption trigger time information and determining whether the magnetic stripe card detection interruption trigger duration exceeds the preset time based on the interruption trigger time information specifically involves: obtaining the expiration time and determining whether the current time has exceeded the expiration time; if so, the magnetic stripe card detection interruption trigger duration exceeds the preset time; otherwise, the magnetic stripe card detection interruption trigger duration does not exceed the preset time.

10. An apparatus for resolving transaction failures caused by non-contact interference, characterized in that, include: The startup module is used to enable contactless startup on the terminal and to enable magnetic stripe card detection interrupt. The detection module is used by the terminal to detect card actions. If a card waving action is detected, the first execution module is triggered; if a card swiping action is detected, the third execution module is triggered. The first execution module is used for the terminal to execute contactless transactions. If the card is detected to be moved during the execution process, the judgment module is triggered; otherwise, the contactless transaction is completed. The judgment module is used by the terminal to determine whether the magnetic stripe card detection interrupt has been triggered. If so, the second execution module is triggered; otherwise, the transaction fails and error handling is performed. The second execution module is used for the terminal to obtain the original data length of the magnetic stripe and the index of the original data buffer of the magnetic stripe, to obtain the original data of the magnetic stripe from the original data buffer of the magnetic stripe according to the original data length of the magnetic stripe and the index of the original data buffer of the magnetic stripe, to decode the original data of the magnetic stripe to obtain magnetic stripe card information, and to execute a card swipe transaction according to the magnetic stripe card information; The third execution module is used by the terminal to execute card swiping transactions; The device further includes: an interrupt processing unit, used to, when a magnetic stripe card enters the terminal card reader, have the terminal collect the original data of the magnetic stripe track and store it in the original data buffer of the magnetic stripe track, trigger the magnetic stripe card detection interrupt, jump to the magnetic stripe card interrupt service routine, record the length of the original data of the magnetic stripe track and the index of the original data buffer of the magnetic stripe track into a global variable, and indicate that the magnetic stripe card detection interrupt has been triggered.

11. An electronic device, characterized in that, include: Processor and memory; The memory is used to store computer programs; The processor is configured to execute the method of any one of claims 1 to 9 by invoking the computer program.

12. A chip system, characterized in that, Including processors and interfaces; The processor is used to implement the method of any one of claims 1 to 9 through the interface.