In fact, one thing they both have in common is to call the unified ordering api
Then I need to change the official account payment to WeChat scan code payment. In fact, to scan the code to pay, I just call the unified ordering api and change the parameters to native. No need to re-write the code
There is no need to rewrite the code. Since it is called unified ordering, the parameters returned by WeChat are all unified, including prepay_id. QR code payment will return a QR code link, and other asynchronous callbacks are unified
It can be done with one class. WeChat payment is quite kind and easy to use. Google it, there are ready-made classes. But it’s not as simple as you said. Different payment methods require different parameters. Not just one payment method is OK, there are other parameters. You can compare the payment parameters. I compared them in detail before.