Minor refactor of doPayment, extracting to separate functions. NFC.
The primary aim of this refactor was to remove the http redirect(), since this means the doPayment function could not be used for embedded checkout in InlayPay. I also tried to split functions so that each did a specific thing, and in particular, to separate out the munging of the payment_params array from the doing-things-with-stripe code. I hope this will make things clearer going forward and more easily integrated in other APIs, like InlayPay.
InlayPay has a stripe-checkout branch which is able to work* with checkout with this PR.
https://lab.civicrm.org/extensions/inlaypay/-/tree/stripe-checkout?ref_type=heads
*work: as in I've had one successful test! It's not prod ready yet!