Assign role in member area

Hi, I need to assign role when a visitor buy a pricing plan. how can I do that?