Buy button after user input

Is there a way a user can advertise (add information to a database) and submit this information after pressing the Buy Button?

I think an easier flow is to allow them to purchase advertisement listing first (let’s say have a buy button saying buy a listing for $5).

Then after they purchase that listing, allow them to add an advertisement listing to your database, and restrict the amount of ads they can add by the amount they have bought.