Payment technology company Global Payments said on Tuesday it would buy peer Total System Services for about $21.5 billion in stock, making it the third mega deal in the industry this year.

The $119.86 per-share value represents a premium of more than 20% to Total System's Thursday close, when reports of a possible deal first emerged. CNBC reported Monday that the Global Payments was nearing a deal to acquire Total System for about $20 billion. Shares of Total System were up 6%. Shares of Global Payments were off about 1.52%.

Global Payments CEO Jeff Sloan on Tuesday told CNBC's "Squawk on the Street" the purchase "allows us to continue to make investments we need to make to stay ahead of the curve."

Payment technology companies are fast consolidating to battle increased competition from banks making inroads into digital payments and fintech start-ups such as Adyen and Stripe chipping away market share.

Fidelity National Information Services agreed to buy Worldpay for about $35 billion in March, months after Fiserv announced a $22 billion takeover of First Data.

"There's never been a period where there's been more innovation in payments than we've seen now," Global Payments' Sloan said.

For Global Payments, it would be its second-biggest acquisition in three years. It bought Heartland Payment Systems in a $4.3 billion cash-and-stock deal in 2016.

The global payment market is set to reach $3 trillion a year in revenue by 2023 as customers opt for digital payments instead of cash, according to consulting firm McKinsey.

The combined company, which will take the name Global Payments, will be led by a 12-member board with six directors.

Sloan will become the CEO of the merged entity and TSYS CEO Troy Woods will become chairman.

The acquisition is expected to close in the fourth quarter of 2019, the company said.

— CNBC's Jessica Bursztynsky contributed to this report