To get permission to leave China’s coronavirus epicenter and return to his job in Hong Kong, a Chinese banker needed two things: a letter from his company and a green health code from an Alibaba app.

The man, who gave his name only as Clarence because of privacy concerns, secured the necessary permission last week and boarded a high-speed train to the border city of Shenzhen.

“It was like the drama ‘Prison Break.’ There are so many levels to go through and so many barriers to overcome,” he said of the challenges of leaving Hubei province.

Alipay by Ant Financial, the finance affiliate controlled by Alibaba Group Holding Ltd. co-founder Jack Ma, and Tencent Holdings Ltd.’s WeChat are credited with helping curb COVID-19 since it erupted in Wuhan in January. Because they’re the primary payments channels for everything from ride-hailing to e-commerce, they already tracked the consumer activity of hundreds of millions of users.

During the outbreak, both companies released QR code systems that can be read by smartphones and determine which individuals pose health risks and need to be quarantined or could be allowed to use public spaces and transportation. Now this technology is proving instrumental in policing the country as it tries to get back on its feet.

Ant’s QR-based health code system assigns each user one of three colors — green, yellow or red — based on their location, basic health information and travel history. Green allows freedom of movement, while yellow and red indicate that one needs to self-quarantine or enter a supervised quarantine facility, respectively.

The colored QR code, which is already deployed in over 200 cities, is obtained by entering information that includes name, national identity number, current location, recent travel history and ticking a box asking if the person has been in contact with an outpatient or anyone hospitalized in the last 14 days. Once everything is complete, a code is automatically generated. Each code is refreshed at midnight.

Cafes, restaurants and shopping malls throughout China also request to see the green QR code before granting permission to enter. Since these health codes were first rolled out by Alipay on Feb. 11 in Hangzhou, adoption by merchants and businesses has been swift across the country with plans for wider deployment, according to Ant Financial.

Rival Tencent worked with a unit of China’s top economic planning body to design a similar program accessible through WeChat mini programs.

A lack of transparency on how colors are generated has led to confusion and frustration with some people taking to social media to complain. Others note technical glitches that have turned into effective travel bans. “These big data platforms have made me really mad,” wrote Weibo user Miuyekanshijie on March 23. “My health code error remains unresolved … it’s seriously affecting my ability to travel.”

RELATED PHOTOS The QR-based health code system by Alipay from Ant Financial assigns each user one of three colors — green, yellow or red — based on their location, basic health information and travel history. Green allows freedom of movement, while yellow and red indicate that you need to self-quarantine or enter a supervised quarantine facility, respectively. | BLOOMBERG