verifyNotify($_POST);
if ($no) {
OrderService::markPaid($no, $_POST['trade_no'] ?? '', 'alipay');
echo 'success';
} else {
echo 'fail';
}
} elseif ($channel === 'wechat') {
$xml = file_get_contents('php://input');
$data = $this->xmlToArray($xml);
$gw = GatewayFactory::make('wechat');
$no = $gw->verifyNotify($data);
if ($no) {
OrderService::markPaid($no, $data['transaction_id'] ?? '', 'wechat');
echo '';
} else {
echo '';
}
} else {
echo 'invalid';
}
exit;
}
private function xmlToArray($xml)
{
$r = @simplexml_load_string($xml, 'SimpleXMLElement', LIBXML_NOCDATA);
return $r ? json_decode(json_encode($r), true) : [];
}
}