Gravity is just applying a force toward the planet. Not just any force, it should depend on the distance from the planet to be closer to real physics.
Something like this:
force 10000/distance(self.X,self.Y,earth.X,earth.Y)^2 toward (planet.x, planet.y)
For an orbit you just set an initial velocity. Using an impulse to do that works too. Just make it perpendicular to the direction to the planet.
Something like this:
impulse: 50/distance(self.X,self.Y,earth.X,earth.Y) at angle(self.X,self.Y,earth.X,earth.Y)+90
The 10000 and 50 were purely arbitrary. I just tuned them till i got something reasonable. the 10000 defined how strong the gravity was, and the 50 gave me orbits that lasted a while.
If you're curious there are perfect values that can be calculated in real life, but the units with the physics behavior are wonky so I just fudged it to get something reasonable.