First you want to isolate him, if you can put him in a hospital tank, anything will work really, where you can keep an eye on his bowel movements, it'll help. A bare bottom is ideal (so you can see the poop!)
It's pretty hard to get a betta to eat a pea, but if you are going to try this, make sure you're doing it right.
Fast him for 2 days. NO FOOD AT ALL. Oh, and don't worry, he won't starve to death! He can go a few weeks without food. Then give him a pea (frozen or fresh is better, canned peas have salt added) that has been cooked, pealed and smooshed up to baby food consistency. Feed this to him at the tip of a flat toothpick if you can.
It might still take another day for the pea to work it's magic, if he eat's it, so give him time.
You don't need any medications, really, just give his body time to process.
But, if it hasn't cleared after 3-4 days, you can try an Epsom salt bath.
Add 1 Tbsp per gallon of Epsom Salt (NOT aquarium salt) to some aged, temperature-adjusted (same temperature as the water the betta is already in) water.
Pour Epsom Salt solution into a containter.
Place the Betta in the Epsom Salt bath for 15-20 minutes.
And remember, do NOT over dose. Epsom salt is made up of Magnesium Sulfate, which can be harmful to your little buddy if he get's too much, so don't do this too often. Max is 2 times a day, but he should be feeling better after the first one. It'll reduce the pressure on his body and make it easier for him to expel.
After the 15-20 min bath, put him back in his hospital tank and just wait, he should be feeling better pretty soon.
And don't try to feed him anything til you're sure he's cleared out. Like I said, he won't starve, even if he gives you those sad betta "feed me" eyes!