提醒1:提交支付请求后微信会同步返回支付结果(后续说明异步的方法)。当返回结果为“系统错误”时,商户系统等待5秒后调用【查询订单API】,查询支付实际交易结果;当返回结果为“USERPAYING”时,商户系统可设置间隔时间(建议10秒)重新查询支付结果,直到支付成功或超时(建议30秒);
我用计划任务做了查询订单API,根据订单支付成功结果修改ecstore表的状态。代码如下:
/**
* 微信检查订单后,修改ecsotre表支付状态
*/
Class checkPay{
public function __construct() {
date_default_timezone_set('Asia/Shanghai');
require_once("../config/config.php");
require_once("./dbase.php");
$this->dbase = new DB();
$this->dbase->connect(DB_HOST, DB_USER, DB_PASSWORD,DB_NAME );
$this->is_log = "./logs/checkPay".date("Ymd").".log";
$this->wx['Appid'] = "*";
$this->wx['mch_id'] = "*";
$this->wx['key'] = "*";