In order to solve the problem of payment in the official account and payment in the mini program, I wrote a js tool file to execute different payment methods according to the current environment (mainly the mini program payment process)
< p> In mini program payment, you need to pay attention to two things. The first is that when package='prepay_id=XXX' is passed to the mini program, the data reception will be incomplete, so only XXX is passed, and 'prepay_id=' is sent to the mini program. It's spliced ??over there; the second point is that '/pages/Pay/Pay' is the page that handles the payment function agreed with the mini program and needs to correspond.Introduce import {payTool} from './PayTool.js'; in the file that needs to be called, and after obtaining the order information, pass in the order information and initiate the payment process payTool(payParam);
p>Obtain order information in the mini program
/wiki/doc/api/wxa/wxa_api.php?chapter=7_7
Use according to the WeChat mini program payment instruction document The received parameters call the payment function
2020.12.24 Supplement
I just learned that there is another qs that can be used,,,
1. npm install qs< /p>
2. var qs = require('qs')
3. There is no need to modify the package, just pass the parameters directly.
There is no need to process the mini program