php - 微信公众号支付完成后,怎么把数据写入数据库
伊谢尔伦
伊谢尔伦 2017-04-17 16:48:45
0
4
1239

初学微信,用的官方微信支付的php DEMO,在自己的服务器调试成功了,想请教下高手,在哪里添加代码后,可以把服务器回调接收到的订单信息写入到自己的数据库。

伊谢尔伦
伊谢尔伦

小伙看你根骨奇佳,潜力无限,来学PHP伐。

reply all(4)
左手右手慢动作

The callback url for successful payment in the demo is the notification address, notify_url() method

刘奇

Log in to WeChat Pay, where you can configure the payment result callback interface. After the WeChat payment is successful, your program interface will be called to pass the payment result information to you. At this time, you can do whatever you want with the information after you get it

Ty80

You can study the payment principles of WeChat payment or Alipay, which mainly include return_url.php and notify_url.php
What you need to use here is notify_url.php. If you judge the transaction is successful here, you can change the order information status and write it to the database. This notification The page can only be started when called by WeChat, and it is between servers. We cannot see it. You can touch and write logs for debugging.

刘奇

Method 1.
First, the code is written in the program location corresponding to the configured notification address. (notify_url)
Then the data returned from the WeChat notification is xml data, which needs to be parsed into the format you need! Pay attention to the cdata data
Method 2 (commonly used) .
The data in the notification class in SDK has been parsed for you. Write a class to continue with the notification class WxPayNotifyWxPayNotify
重写NotifyProcessRewrite the NotifyProcess function (the location of your code), example Just call it and handle

PS: The WeChat payment SDK code is so messy...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template