Ripple, the startup behind the XRP cryptocurrency, has agreed to invest up to $50m in MoneyGram, the giant money-transfer service.