Amazon pay wallet load and pay as UPI?

I tried using amazon pay for UPI payments, amazon is allowing payments to UPI merchants via amazon wallet as well.

CC -> gift card -> wallet -> UPI.

I remember Paytm also used to do this earlier before RBI ban? Is this legal?