Praise be to Allah.
If the period began and blood appeared before the sun set, you should regard yourself as having broken the fast, and you have to make up this day. But the pains that appeared before that do not invalidate the fast. Pain due to the fact that menstruation is close at hand does not invalidate the fast. So if the pain continued but there was no bleeding until the sun set, then the fast is valid and you do not have to make up this day.
But if bleeding starts before the sun sets, even if it is only five minutes before, then this fast is invalidated and you have to make it up. This is the shar‘i ruling as far as we know. With regard to the pains, there are medicines and treatments for that; you should ask doctors, and perhaps you will find with them that will relieve you of this pain you are feeling.
Shaykh ‘Abd al-‘Azeez ibn Baaz (may Allah have mercy on him)