One possibility is injury to the joint. When there is a capsular injury to a joint in finger, it is best to give the RICE treatment for a few days such as rest, ice application, compression bandage (you can strap the injured finger with the neighboring finger) and elevation (keep hands elevated on a pillow at bed time). You can also take an anti-inflammatory pain killer. Once the injury settles down and there is less pain you have to start physiotherapy. Bend and extend the finger at the joint slowly to a range of motion possible without pain. Slowly increase the range of motion. With time the stiffness will go. You can also consult a sports injury center.
Other possibilities are arthritis-rheumatoid, injury, inflammation of the sac of joint, finger prick, insect bite, allergy or contact dermatitis to something, tendon injury or inflammation, clot in blood vessel, infection of the skin or pulp of the finger etc.
I think you should discuss these possibilities with your doctor. It is difficult to comment beyond this without examining. Take care!