微信客户端下载安装使用H5网页端调起支付(jsApi),报错误信息:get_brand_wcpay_request:fail,请指教?

问题补充&&
本页链接:
猜你感兴趣
服务声明: 信息来源于互联网,不保证内容的可靠性、真实性及准确性,仅供参考,版权归原作者所有!Copyright &
Powered by手机网页调微信支付,设置里notify_url没回调
[问题点数:100分,结帖人JaniTang2011]
手机网页调微信支付,设置里notify_url没回调
[问题点数:100分,结帖人JaniTang2011]
不显示删除回复
显示所有回复
显示星级回复
显示得分回复
只显示楼主
2015年5月 PHP大版内专家分月排行榜第三2014年5月 PHP大版内专家分月排行榜第三
2011年11月 PHP大版内专家分月排行榜第二
匿名用户不能发表回复!|
每天回帖即可获得10分可用分!小技巧:
你还可以输入10000个字符
(Ctrl+Enter)
请遵守CSDN,不得违反国家法律法规。
转载文章请注明出自“CSDN(www.csdn.net)”。如是商业用途请联系原作者。Java实现JsApi方式的微信支付 - 推酷
Java实现JsApi方式的微信支付
要使用JsApi进行微信支付,首先要从微信获得一个prepay_id,然后通过调用微信的jsapi完成支付,JS API的返回结果get_brand_wcpay_request:ok仅在用户成功完成支付时返回。由于前端交互复杂,get_brand_wcpay_request:cancel或者get_brand_wcpay_request:fail可以统一处理为用户遇到错误或者主动放弃,不必细化区分。示例代码如下:
function onBridgeReady(){
WeixinJSBridge.invoke(
'getBrandWCPayRequest', {
&appId& : &wx0ec43b&,
//公众号名称,由商户传入
&timeStamp&:& &,
//时间戳,自1970年以来的秒数
&nonceStr& : &e61463f8efacccfbbb444&, //随机串
&package& : &u802345jgfjsdfgsdg888&,
&signType& : &MD5&,
//微信签名方式:
&paySign& : &70EABB79628FBCAFADD89& //微信签名
function(res){
if(res.err_msg == &get_brand_wcpay_request:ok& ) {}
// 使用以上方式判断前端返回,微信团队郑重提示:res.err_msg将在用户支付成功后返回 ok,但并不保证它绝对可靠。
if (typeof WeixinJSBridge == &undefined&){
if( document.addEventListener ){
document.addEventListener('WeixinJSBridgeReady', onBridgeReady, false);
}else if (document.attachEvent){
document.attachEvent('WeixinJSBridgeReady', onBridgeReady);
document.attachEvent('onWeixinJSBridgeReady', onBridgeReady);
onBridgeReady();
以上传入的参数package,即为prepay_id
详细文档见:
下面讲的是获得参数来调用jsapi
我们调用JSAPI时,必须获得用户的openid,(trade_type=JSAPI,openid为必填参数。)
首先定义一个请求的对象:
package com.unstoppedable.
import mon.C
import mon.HttpS
import mon.RandomStringG
import mon.S
import java.lang.reflect.F
import java.util.HashM
import java.util.M
public class UnifiedOrderReqData {
private String mch_
private String device_
private String nonce_
private String out_trade_
private String fee_
private int total_
private String spbill_create_
private String time_
private String time_
private String goods_
private String notify_
private String trade_
private String product_
private String limit_
private UnifiedOrderReqData(UnifiedOrderReqDataBuilder builder) {
this.appid = builder.
this.mch_id = builder.mch_
this.device_info = builder.device_
this.nonce_str = RandomStringGenerator.getRandomStringByLength(32);
this.body = builder.
this.detail = builder.
this.attach = builder.
this.out_trade_no = builder.out_trade_
this.fee_type = builder.fee_
this.total_fee = builder.total_
this.spbill_create_ip = builder.spbill_create_
this.time_start = builder.time_
this.time_expire = builder.time_
this.goods_tag = builder.goods_
this.notify_url = builder.notify_
this.trade_type = builder.trade_
this.product_id = builder.product_
this.limit_pay = builder.limit_
this.openid = builder.
this.sign = Signature.getSign(toMap());
public void setAppid(String appid) {
this.appid =
public void setMch_id(String mch_id) {
this.mch_id = mch_
public void setDevice_info(String device_info) {
this.device_info = device_
public void setNonce_str(String nonce_str) {
this.nonce_str = nonce_
public void setSign(String sign) {
this.sign =
public void setBody(String body) {
this.body =
public void setDetail(String detail) {
this.detail =
public void setAttach(String attach) {
this.attach =
public void setOut_trade_no(String out_trade_no) {
this.out_trade_no = out_trade_
public void setFee_type(String fee_type) {
this.fee_type = fee_
public void setTotal_fee(int total_fee) {
this.total_fee = total_
public void setSpbill_create_ip(String spbill_create_ip) {
this.spbill_create_ip = spbill_create_
public void setTime_start(String time_start) {
this.time_start = time_
public void setTime_expire(String time_expire) {
this.time_expire = time_
public void setGoods_tag(String goods_tag) {
this.goods_tag = goods_
public void setNotify_url(String notify_url) {
this.notify_url = notify_
public void setTrade_type(String trade_type) {
this.trade_type = trade_
public void setProduct_id(String product_id) {
this.product_id = product_
public void setLimit_pay(String limit_pay) {
this.limit_pay = limit_
public void setOpenid(String openid) {
this.openid =
public Map&String, Object& toMap() {
Map&String, Object& map = new HashMap&String, Object&();
Field[] fields = this.getClass().getDeclaredFields();
for (Field field : fields) {
obj = field.get(this);
if (obj != null) {
map.put(field.getName(), obj);
} catch (IllegalArgumentException e) {
e.printStackTrace();
} catch (IllegalAccessException e) {
e.printStackTrace();
public static class UnifiedOrderReqDataBuilder {
private String mch_
private String device_
private String out_trade_
private String fee_
private int total_
private String spbill_create_
private String time_
private String time_
private String goods_
private String notify_
private String trade_
private String product_
private String limit_
public UnifiedOrderReqDataBuilder(String appid, String mch_id, String body, String out_trade_no, Integer total_fee,
String spbill_create_ip, String notify_url, String trade_type) {
if (appid == null) {
throw new IllegalArgumentException(&传入参数appid不能为null&);
if (mch_id == null) {
throw new IllegalArgumentException(&传入参数mch_id不能为null&);
if (body == null) {
throw new IllegalArgumentException(&传入参数body不能为null&);
if (out_trade_no == null) {
throw new IllegalArgumentException(&传入参数out_trade_no不能为null&);
if (total_fee == null) {
throw new IllegalArgumentException(&传入参数total_fee不能为null&);
if (spbill_create_ip == null) {
throw new IllegalArgumentException(&传入参数spbill_create_ip不能为null&);
if (notify_url == null) {
throw new IllegalArgumentException(&传入参数notify_url不能为null&);
if (trade_type == null) {
throw new IllegalArgumentException(&传入参数trade_type不能为null&);
this.appid =
this.mch_id = mch_
this.body =
this.out_trade_no = out_trade_
this.total_fee = total_
this.spbill_create_ip = spbill_create_
this.notify_url = notify_
this.trade_type = trade_
public UnifiedOrderReqDataBuilder setDevice_info(String device_info) {
this.device_info = device_
public UnifiedOrderReqDataBuilder setDetail(String detail) {
this.detail =
public UnifiedOrderReqDataBuilder setAttach(String attach) {
this.attach =
public UnifiedOrderReqDataBuilder setFee_type(String fee_type) {
this.fee_type = fee_
public UnifiedOrderReqDataBuilder setTime_start(String time_start) {
this.time_start = time_
public UnifiedOrderReqDataBuilder setTime_expire(String time_expire) {
this.time_expire = time_
public UnifiedOrderReqDataBuilder setGoods_tag(String goods_tag) {
this.goods_tag = goods_
public UnifiedOrderReqDataBuilder setProduct_id(String product_id) {
this.product_id = product_
public UnifiedOrderReqDataBuilder setLimit_pay(String limit_pay) {
this.limit_pay = limit_
public UnifiedOrderReqDataBuilder setOpenid(String openid) {
this.openid =
public UnifiedOrderReqData build() {
if(&JSAPI&.equals(this.trade_type) && this.openid == null) {
throw new IllegalArgumentException(&当传入trade_type为JSAPI时,openid为必填参数&);
if(&NATIVE&.equals(this.trade_type) && this.product_id == null) {
throw new IllegalArgumentException(&当传入trade_type为NATIVE时,product_id为必填参数&);
return new UnifiedOrderReqData(this);
因为有些参数为必填,有些参数为选填。而且sign要等所有参数传入之后才能计算的出,所以这里用了builder模式。关于builder模式。关于每个参数的定义,参考说明文档https://pay./wiki/doc/api/jsapi.php?chapter=9_1
我们选用httpclient进行网络传输。
import com.thoughtworks.xstream.XS
import com.thoughtworks.xstream.io.xml.DomD
import com.thoughtworks.xstream.io.xml.XmlFriendlyNameC
import mons.logging.L
import mons.logging.LogF
import org.apache.http.HttpE
import org.apache.http.HttpR
import org.apache.http.client.ClientProtocolE
import org.apache.http.client.ResponseH
import org.apache.http.client.config.RequestC
import org.apache.http.client.methods.HttpG
import org.apache.http.client.methods.HttpP
import org.apache.http.conn.ConnectTimeoutE
import org.apache.http.conn.ConnectionPoolTimeoutE
import org.apache.http.conn.ssl.SSLConnectionSocketF
import org.apache.http.conn.ssl.SSLC
import org.apache.http.entity.StringE
import org.apache.http.impl.client.CloseableHttpC
import org.apache.http.impl.client.HttpC
import org.apache.http.util.EntityU
import javax.net.ssl.SSLC
import java.io.F
import java.io.FileInputS
import java.io.IOE
import java.net.SocketTimeoutE
import java.security.KeyS
* Created by hupeng on .
public class HttpService {
private static Log logger = LogFactory.getLog(HttpService.class);
private static CloseableHttpClient httpClient = buildHttpClient();
//连接超时时间,默认10秒
private static int socketTimeout = 5000;
//传输超时时间,默认30秒
private static int connectTimeout = 5000;
private static int requestTimeout = 5000;
public static CloseableHttpClient buildHttpClient() {
KeyStore keyStore = KeyStore.getInstance(&PKCS12&);
FileInputStream instream = new FileInputStream(new File(Configure.getCertLocalPath()));//加载本地的证书进行https加密传输
keyStore.load(instream, Configure.getCertPassword().toCharArray());//设置证书密码
} finally {
instream.close();
// Trust own CA and all self-signed certs
SSLContext sslcontext = SSLContexts.custom()
.loadKeyMaterial(keyStore, Configure.getCertPassword().toCharArray())
// Allow TLSv1 protocol only
SSLConnectionSocketFactory sslsf = new SSLConnectionSocketFactory(
sslcontext,
new String[]{&TLSv1&},
SSLConnectionSocketFactory.BROWSER_COMPATIBLE_HOSTNAME_VERIFIER);
RequestConfig requestConfig = RequestConfig.custom()
.setConnectTimeout(connectTimeout)
.setConnectionRequestTimeout(requestTimeout)
.setSocketTimeout(socketTimeout).build();
httpClient = HttpClients.custom()
.setDefaultRequestConfig(requestConfig)
.setSSLSocketFactory(sslsf)
return httpC
} catch (Exception e) {
throw new RuntimeException(&error create httpclient......&, e);
public static String doGet(String requestUrl) throws Exception {
HttpGet httpget = new HttpGet(requestUrl);
logger.debug(&Executing request & + httpget.getRequestLine());
// Create a custom response handler
ResponseHandler&String& responseHandler = new ResponseHandler&String&() {
public String handleResponse(
final HttpResponse response) throws ClientProtocolException, IOException {
int status = response.getStatusLine().getStatusCode();
if (status &= 200 && status & 300) {
HttpEntity entity = response.getEntity();
return entity != null ? EntityUtils.toString(entity) :
throw new ClientProtocolException(&Unexpected response status: & + status);
return httpClient.execute(httpget, responseHandler);
} finally {
httpget.releaseConnection();
public static String doPost(String url, Object object2Xml) {
String result =
HttpPost httpPost = new HttpPost(url);
//解决XStream对出现双下划线的bug
XStream xStreamForRequestPostData = new XStream(new DomDriver(&UTF-8&, new XmlFriendlyNameCoder(&-_&, &_&)));
//将要提交给API的数据对象转换成XML格式数据Post给API
String postDataXML = xStreamForRequestPostData.toXML(object2Xml);
(&API,POST过去的数据是:&);
(postDataXML);
//得指明使用UTF-8编码,否则到API服务器XML的中文不能被成功识别
StringEntity postEntity = new StringEntity(postDataXML, &UTF-8&);
httpPost.addHeader(&Content-Type&, &text/xml&);
httpPost.setEntity(postEntity);
//设置请求器的配置
(&executing request& + httpPost.getRequestLine());
HttpResponse response = httpClient.execute(httpPost);
HttpEntity entity = response.getEntity();
result = EntityUtils.toString(entity, &UTF-8&);
} catch (ConnectionPoolTimeoutException e) {
logger.error(&http get throw ConnectionPoolTimeoutException(wait time out)&, e);
} catch (ConnectTimeoutException e) {
logger.error(&http get throw ConnectTimeoutException&, e);
} catch (SocketTimeoutException e) {
logger.error(&http get throw SocketTimeoutException&, e);
} catch (Exception e) {
logger.error(&http get throw Exception&, e);
} finally {
httpPost.abort();
然后是我们的总入口:
package com.unstoppedable.
import mon.C
import mon.HttpS
import mon.XMLP
import com.unstoppedable.protocol.UnifiedOrderReqD
import org.xml.sax.SAXE
import javax.xml.parsers.ParserConfigurationE
import java.io.IOE
import java.util.M
* Created by hupeng on .
public class WxPayApi {
public static Map&String,Object& UnifiedOrder(UnifiedOrderReqData reqData) throws IOException, SAXException, ParserConfigurationException {
String res
= HttpService.doPost(Configure.UNIFIED_ORDER_API, reqData);
return XMLParser.getMapFromXML(res);
public static void main(String[] args) throws Exception {
UnifiedOrderReqData reqData = new UnifiedOrderReqData.UnifiedOrderReqDataBuilder(&appid&, &mch_id&, &body&, &out_trade_no&, 1, &spbill_create_ip&, &notify_url&, &JSAPI&).setOpenid(&openid&).build();
System.out.println(UnifiedOrder(reqData));
返回的xml为:
&return_code&&![CDATA[SUCCESS]]&&/return_code&
&return_msg&&![CDATA[OK]]&&/return_msg&
&appid&&![CDATA[wx0ec43b]]&&/appid&
&mch_id&&![CDATA[]]&&/mch_id&
&nonce_str&&![CDATA[IITRi8Iabbblz1Jc]]&&/nonce_str&
&sign&&![CDATA[EB8ED0CED72F]]&&/sign&
&result_code&&![CDATA[SUCCESS]]&&/result_code&
&prepay_id&&![CDATA[wx507cbf6ffd8b]]&&/prepay_id&
&trade_type&&![CDATA[JSAPI]]&&/trade_type&
return_code 和result_code都为SUCCESS的时候会返回我们需要的prepay_id。。。
然后在jsapi中使用他就可以了。。
代码托管在/hupengcool/wxpay_jsapi ,欢迎指正
已发表评论数()
&&登&&&录&&
已收藏到推刊!
请填写推刊名
描述不能大于100个字符!
权限设置: 公开
仅自己可见原文:首先微信支付需注册 &微信公从平台开发 和 微信支付商户平台
关于4个密钥,如何获得:有图
AppID(应用ID)    :wx (来自微信公众平台-》开发者中心-》配置项-》开发者ID-》AppID(应用ID))
AppSecret(应用密钥) :62d0000000ae (来自微信公众平台-》开发者中心-》配置项-》开发者ID-》AppSecret(应用密钥))
商户号        :0000000 (来自微信支付商户平台-》帐号设置 -》帐号信息-》基本帐号信息-》微信支付商户号: (小知:纯数字))
商户密钥:   :0c0000000b (来自您申请微信支付商户平台时发送到你邮件里的一串码,若丢失,可重新申请,步骤:商户平台-》帐户设置-》API安全-》API密钥-》右下角有&设置密钥&)
关于代码,我将整理为一个页面:wxpay.php
header("Content-type: text/ charset=utf-8");
$wx = new wxpay();
$payment = array(
'wxpay_AppSecret' =& '0c830ab0b',//(来自您申请微信支付商户平台时发送到你邮件里的一串码,若丢失,可重新申请,步骤:商户平台-》帐户设置-》API安全-》API密钥-》右下角有&设置密钥&)
'wxpay_AppID' =& 'wx',//(来自微信公众平台-》开发者中心-》配置项-》开发者ID-》AppID(应用ID))
'wxpay_shanghuID' =& '',//(来自微信支付商户平台-》帐号设置 -》帐号信息-》基本帐号信息-》微信支付商户号: (小知:纯数字))
$order = array(
'order_sn' =& '',//这是订单SN
'order_amount' =& 0.01, //金额
$openid = 'oT0000GNkNM3s';//此OPENID是微信的唯一标识,需用API获得,此贴按下不表,择日发贴$notify_url = "/auth/respond.php";//必须是授权目录/auth/
echo $wx-&get_code($openid, $order, $payment);
* 微信支付类
class wxpay
var $ // cft 参数
var $ // 配置信息
* 生成支付代码
* @param array $order
* 订单信息
* @param array $payment
* 支付方式信息
function get_code($openid, $order, $payment, $notify_url)
// 配置参数
$this-&payment = $
//设置必填参数
//根目录url
$out_trade_no = $order['order_sn'] . 'o' . rand(1, 100);
$this-&setParameter('body', $order['order_sn']);
$this-&setParameter("openid", "{$openid}");//用户唯一标识
$this-&setParameter("out_trade_no", $out_trade_no);//商户订单号
$this-&setParameter("total_fee", $order['order_amount'] * 100);//总金额
$this-&setParameter("notify_url", "{$notify_url}");//通知地址
$this-&setParameter("trade_type", "JSAPI");//交易类型
$prepay_id = $this-&getPrepayId();
$jsApiParameters = $this-&getParameters($prepay_id);
// wxjsbridge
$js = '&script type="text/javascript"&
function jsApiCall(){WeixinJSBridge.invoke("getBrandWCPayRequest",'.$jsApiParameters.',function(res){if(res.err_msg == "get_brand_wcpay_request:ok"){location.href="/respond.php?code=wxpay&status=1&subject='.$out_trade_no.'"}else{window.location.href="respond.php?code=wxpay&status=0&subject="}});}function callpay(){if (typeof WeixinJSBridge == "undefined"){if( document.addEventListener ){document.addEventListener("WeixinJSBridgeReady", jsApiCall, false);}else if (document.attachEvent){document.attachEvent("WeixinJSBridgeReady", jsApiCall);document.attachEvent("onWeixinJSBridgeReady", jsApiCall);}}else{jsApiCall();}}
&/script&';
$button = '&div style="text-align:center"&&button class="c-btn3" type="button" onclick="callpay()" style="background:#f16681;display:inline-padding:5px 10border-radius:3font-size:14color:#border:1px solid #" &微信安全支付&/button&&/div&' . $
function trimString($value)
if (null != $value)
if (strlen($ret) == 0)
作用:产生随机字符串,不长于32位
public function createNoncestr( $length = 32 )
$chars = "abcdefghijklmnopqrstuvwxyz";
for ( $i = 0; $i & $ $i++ )
$str.= substr($chars, mt_rand(0, strlen($chars)-1), 1);
作用:设置请求参数
function setParameter($parameter, $parameterValue)
$this-&parameters[$this-&trimString($parameter)] = $this-&trimString($parameterValue);
作用:生成签名
public function getSign($Obj)
foreach ($Obj as $k =& $v)
$Parameters[$k] = $v;
//签名步骤一:按字典序排序参数
ksort($Parameters);
$buff = "";
foreach ($Parameters as $k =& $v)
$buff .= $k . "=" . $v . "&";
if (strlen($buff) & 0)
$String = substr($buff, 0, strlen($buff)-1);
//echo '【string1】'.$String.'&/br&';
//签名步骤二:在string后加入KEY
$String = $String."&key=".$this-&payment['wxpay_AppSecret'];
//echo "【string2】".$String."&/br&";
//签名步骤三:MD5加密
$String = md5($String);
//echo "【string3】 ".$String."&/br&";
//签名步骤四:所有字符转为大写
$result_ = strtoupper($String);
//echo "【result】 ".$result_."&/br&";
return $result_;
作用:以post方式提交xml到对应的接口url
public function postXmlCurl($xml,$url,$second=30)
//初始化curl
$ch = curl_init();
//设置超时
curl_setopt($ch, CURLOP_TIMEOUT, $second);
//这里设置代理,如果有的话
//curl_setopt($ch,CURLOPT_PROXY, '8.8.8.8');
//curl_setopt($ch,CURLOPT_PROXYPORT, 8080);
curl_setopt($ch,CURLOPT_URL, $url);
curl_setopt($ch,CURLOPT_SSL_VERIFYPEER,FALSE);
curl_setopt($ch,CURLOPT_SSL_VERIFYHOST,FALSE);
//设置header
curl_setopt($ch, CURLOPT_HEADER, FALSE);
//要求结果为字符串且输出到屏幕上
curl_setopt($ch, CURLOPT_RETURNTRANSFER, TRUE);
//post提交方式
curl_setopt($ch, CURLOPT_POST, TRUE);
curl_setopt($ch, CURLOPT_POSTFIELDS, $xml);
//运行curl
$data = curl_exec($ch);
curl_close($ch);
//返回结果
curl_close($ch);
$error = curl_errno($ch);
echo "curl出错,错误码:$error"."&br&";
echo "&a href='http://curl.haxx.se/libcurl/c/libcurl-errors.html'&错误原因查询&/a&&/br&";
curl_close($ch);
* 获取prepay_id
function getPrepayId()
//设置接口链接
$url = "https://api.mch./pay/unifiedorder";
//检测必填参数
if($this-&parameters["out_trade_no"] == null){
throw new Exception("缺少统一支付接口必填参数out_trade_no!"."&br&");
}elseif($this-&parameters["body"] == null){
throw new Exception("缺少统一支付接口必填参数body!"."&br&");
}elseif ($this-&parameters["total_fee"] == null ) {
throw new Exception("缺少统一支付接口必填参数total_fee!"."&br&");
}elseif ($this-&parameters["notify_url"] == null) {
throw new Exception("缺少统一支付接口必填参数notify_url!"."&br&");
}elseif ($this-&parameters["trade_type"] == null) {
throw new Exception("缺少统一支付接口必填参数trade_type!"."&br&");
}elseif ($this-&parameters["trade_type"] == "JSAPI" && $this-&parameters["openid"] == NULL){
throw new Exception("统一支付接口中,缺少必填参数openid!trade_type为JSAPI时,openid为必填参数!"."&br&");
$this-&parameters["appid"] = $this-&payment['wxpay_AppID'];//公众账号ID
$this-&parameters["mch_id"] = $this-&payment['wxpay_shanghuID'];//商户号
$this-&parameters["spbill_create_ip"] = $_SERVER['REMOTE_ADDR'];//终端ip
$this-&parameters["nonce_str"] = $this-&createNoncestr();//随机字符串
$this-&parameters["sign"] = $this-&getSign($this-&parameters);//签名
$xml = "&xml&";
foreach ($this-&parameters as $key=&$val)
if (is_numeric($val))
$xml.="&".$key."&".$val."&/".$key."&";
$xml.="&".$key."&&![CDATA[".$val."]]&&/".$key."&";
$xml.="&/xml&";
}catch (Exception $e)
die($e-&getMessage());
$response = $this-&postXmlCurl($xml, $url, 30);
$result = json_decode(json_encode(simplexml_load_string($response, 'SimpleXMLElement', LIBXML_NOCDATA)), true);
$prepay_id = $result["prepay_id"];
return $prepay_
作用:设置jsapi的参数
public function getParameters($prepay_id)
$timeStamp = time();
$jsApiObj["appId"] = $this-&payment['wxpay_AppID'];
$jsApiObj["timeStamp"] = "$timeStamp";
$jsApiObj["nonceStr"] = $this-&createNoncestr();
$jsApiObj["package"] = "prepay_id=$prepay_id";
$jsApiObj["signType"] = "MD5";
$jsApiObj["paySign"] = $this-&getSign($jsApiObj);
$this-&parameters = json_encode($jsApiObj);
return $this-&
关于报&getRrandWCPayRequest:fail_invalid appid 错误。
我的代码是基于ecshop开发的。一直报错。后来单狂拿出来,整理一个文件。将代码放在根目录的auth目录下。
支付目录是 /auth/wxpay.php (wxpay.php则是上面的代码)
授权目录则是 /auth/
(重点说明:授权目录填写是你支付的页面在哪个目录下就填当前目录下的目录。否则出错,不会弹出支付窗口。)
(经多次测试,如果在网站的根目录下,即使授权了,也报&getRrandWCPayRequest:fail_invalid appid 错误,解决方法则是:放在某目录下,再授权此目录,如果是根目录下,无法完成支付,必须要二级目录或三级等,不知这是微信硬性规定还是BUG)
关于返回页面,如下。放在当前支付目录下。respond.php
&!DOCTYPE html&
&meta charset="utf-8"&
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
if($_REQUEST['status'] == 1 && isset($_REQUEST['subject'])) {
echo '支付成功';
echo "支付失败";
Views(...) Comments()

我要回帖

更多关于 客户端 的文章

 

随机推荐