根据购物车中价格最高的产品类别显示支付网关

I have an unique problem. I have to show payment gateway as per the product category. but in case of multiple products from different category in the cart, the category of the highest price product will be selected and the payment gateway will be shown as per that category.

Logic: (This is not a code snippet)

Product of Category 1 -> Payment Gateway 1

but if multiple products are in the cart

Product 1 (Category 1): Price $50
Product 2 (Category 2): Price $70

then Payment gateway 2 will be shown because category 2 product has higher price.

I found a plugin called Payment Gateways per Products for WooCommerce to solve the first problem (i:e; show payment gateway by category) but I am stuck at the 2nd half of the problem. Please help.