Connecting external payment option and redirecting back after successful payment

I want to connect to an external payment like payu or razorpay for payment and redirecting back after the payment and saving payment status.

The general process could be something like:

  1. have users click a button that opens your payment processor in a new tab. Users pay there.
  2. once clicked, that button becomes a refresh button that every time its pressed makes an API call to your payment processor to see if that user has paid
  3. if that API call determines the user has paid you could store “payment = successful” or whatever as a variable using Global Config so the app remembers that they’ve paid.