They'll mostly fly away. If you have lots of nectar and host plants that they like some may stick around for a while. But, if you have lots of nectar and host plants then the plants will likely attract plenty of butterflies, so that you don't have to buy any! The best long term plan is to make a nice habitat for the butterflies and they'll come on their own. Then you can collect eggs or caterpillars off your own plants to protect from predators and raise if you want to watch their life cycle.
Buying them online is not something I would do personally. Some of those sellers may be contributing to introducing non-native species or diseased individuals into areas.