Your site, the customer, and the payment provider (Safaricom Daraja, Paystack, Stripe). Your site never touches a PIN or card number. That is the entire reason to use a provider.
Never mark an order paid because the BROWSER said so. A redirect back to success.php?status=paid can be typed by anyone. The confirmation must come from your server talking to the provider's server, or from a signed callback you verify.
The pending row exists before any money moves. Otherwise a callback arrives referring to something you have no record of, and you are reconciling by hand.
Generate an unguessable reference, bin2hex(random_bytes(8)), not order number 1, 2, 3. Sequential references let someone probe other people's orders.