Nowadays, using APP WeChat payment has become the mainstream payment mode. Below, the editor will introduce to you an example explanation of how to implement APP WeChat payment through PHP. , it is simple and easy to learn. Let’s learn APP with the editor Pay with WeChat.
1. The PHP background generates a prepayment transaction order, returns the correct prepayment transaction response ID, and then calls up the payment in the APP!
Official document:https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_1
Spliced according to the document The parameters required by WeChat need several methods. Just upload the code!
The parameters transmitted to WeChat must be assembled into xml format and sent as parameter array!
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
|
2. Generate random characters String, the parameters required by WeChat! There are many methods here, it depends on your hobbies!
1 2 3 4 5 6 |
|
3. This is an important step for WeChat, this method will be used many times! Generate signature
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
|
4. Pass the parameters to WeChat and generate a pre-payment order! Receive the data returned by WeChat and send it back to the APP. The APP calls the payment interface to complete the payment! For the parameters required on the APP, please see the WeChat documentation: https://pay. weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_12&index=2
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 |
|
5. Convert xml data into an array, used when receiving data returned by WeChat.
1 2 3 4 5 6 7 8 9 10 11 |
|
2. After the APP payment is successful, it will call the callback address you filled in.
For details of the return parameters, please refer to the WeChat documentation: https://pay. weixin.qq.com/wiki/doc/api/app/app.php?chapter=9_7&index=3
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 |
|
Here, the WeChat APP payment process is completed successfully! Thank you for your support!
The above is the specific method of implementing APP WeChat payment in PHP. Through the editor's example explanation, I believe everyone has mastered it.
Related recommendations:
Alarm notification example of WeChat payment
WeChat refund function example of PHP WeChat payment development
Thinkphp integrated WeChat payment function detailed explanation
The above is the detailed content of Example analysis of implementing APP WeChat payment through PHP. For more information, please follow other related articles on the PHP Chinese website!