微信支付:新增授权码查询OPENID接口
This commit is contained in:
parent
4ab6fef02e
commit
ed4cb18c00
@ -28,6 +28,7 @@ import com.foxinmy.weixin4j.model.WeixinPayAccount;
|
||||
import com.foxinmy.weixin4j.payment.PayURLConsts;
|
||||
import com.foxinmy.weixin4j.payment.PayUtil;
|
||||
import com.foxinmy.weixin4j.payment.mch.ApiResult;
|
||||
import com.foxinmy.weixin4j.payment.mch.AuthCodeOpenIdResult;
|
||||
import com.foxinmy.weixin4j.payment.mch.Order;
|
||||
import com.foxinmy.weixin4j.payment.mch.RefundRecord;
|
||||
import com.foxinmy.weixin4j.payment.mch.RefundResult;
|
||||
@ -430,6 +431,30 @@ public class Pay3Api {
|
||||
return response.getAsXmlResult();
|
||||
}
|
||||
|
||||
/**
|
||||
* 授权码查询OPENID接口
|
||||
*
|
||||
* @param authCode
|
||||
* 扫码支付授权码,设备读取用户微信中的条码或者二维码信息
|
||||
* @return 查询结果
|
||||
* @see com.foxinmy.weixin4j.payment.mch.AuthCodeOpenIdResult
|
||||
* @see <a
|
||||
* href="https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_13&index=9">授权码查询OPENID</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public AuthCodeOpenIdResult authCode2openId(String authCode)
|
||||
throws WeixinException {
|
||||
Map<String, String> map = baseMap(null);
|
||||
map.put("auth_code", authCode);
|
||||
String sign = PayUtil.paysignMd5(map, weixinAccount.getPaySignKey());
|
||||
map.put("sign", sign);
|
||||
String param = XmlStream.map2xml(map);
|
||||
WeixinResponse response = weixinClient.post(
|
||||
PayURLConsts.MCH_AUTHCODE_OPENID_URL, param);
|
||||
return response.getAsObject(new TypeReference<AuthCodeOpenIdResult>() {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* V3接口请求基本数据
|
||||
*
|
||||
|
||||
@ -102,9 +102,15 @@ public final class PayURLConsts {
|
||||
* 商户平台下native支付的url-模式1
|
||||
*/
|
||||
public static final String MCH_NATIVE_URL1 = "weixin://wxpay/bizpayurl?sign=%s&appid=%s&mch_id=%s&product_id=%s&time_stamp=%s&nonce_str=%s";
|
||||
|
||||
|
||||
/**
|
||||
* 商户平台下native支付的url-模式2
|
||||
*/
|
||||
public static final String MCH_NATIVE_URL2 = "weixin://wxpay/bizpayurl?sr=%s";
|
||||
|
||||
/**
|
||||
* 授权码查询OPENID接口
|
||||
*/
|
||||
public static final String MCH_AUTHCODE_OPENID_URL = MCH_BASE_URL
|
||||
+ "/tools/authcodetoopenid";
|
||||
}
|
||||
|
||||
@ -17,6 +17,7 @@ import com.foxinmy.weixin4j.payment.coupon.CouponDetail;
|
||||
import com.foxinmy.weixin4j.payment.coupon.CouponResult;
|
||||
import com.foxinmy.weixin4j.payment.coupon.CouponStock;
|
||||
import com.foxinmy.weixin4j.payment.mch.ApiResult;
|
||||
import com.foxinmy.weixin4j.payment.mch.AuthCodeOpenIdResult;
|
||||
import com.foxinmy.weixin4j.payment.mch.MPPayment;
|
||||
import com.foxinmy.weixin4j.payment.mch.MPPaymentRecord;
|
||||
import com.foxinmy.weixin4j.payment.mch.MPPaymentResult;
|
||||
@ -505,4 +506,21 @@ public class WeixinPayProxy {
|
||||
return cashApi.mchPaymentQuery(new FileInputStream(DEFAULT_CA_FILE),
|
||||
outTradeNo);
|
||||
}
|
||||
|
||||
/**
|
||||
* 授权码查询OPENID接口
|
||||
*
|
||||
* @param authCode
|
||||
* 扫码支付授权码,设备读取用户微信中的条码或者二维码信息
|
||||
* @return 查询结果
|
||||
* @see com.foxinmy.weixin4j.api.CashApi
|
||||
* @see com.foxinmy.weixin4j.payment.mch.AuthCodeOpenIdResult
|
||||
* @see <a
|
||||
* href="https://pay.weixin.qq.com/wiki/doc/api/micropay.php?chapter=9_13&index=9">授权码查询OPENID</a>
|
||||
* @throws WeixinException
|
||||
*/
|
||||
public AuthCodeOpenIdResult authCode2openId(String authCode)
|
||||
throws WeixinException {
|
||||
return pay3Api.authCode2openId(authCode);
|
||||
}
|
||||
}
|
||||
|
||||
@ -0,0 +1,41 @@
|
||||
package com.foxinmy.weixin4j.payment.mch;
|
||||
|
||||
import javax.xml.bind.annotation.XmlAccessType;
|
||||
import javax.xml.bind.annotation.XmlAccessorType;
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
import com.alibaba.fastjson.annotation.JSONField;
|
||||
|
||||
/**
|
||||
* authcode2openid
|
||||
*
|
||||
* @className AuthCodeOpenIdResult
|
||||
* @author jy
|
||||
* @date 2015年7月23日
|
||||
* @since JDK 1.7
|
||||
* @see
|
||||
*/
|
||||
@XmlRootElement
|
||||
@XmlAccessorType(XmlAccessType.FIELD)
|
||||
public class AuthCodeOpenIdResult extends ApiResult {
|
||||
|
||||
private static final long serialVersionUID = 902743989722741814L;
|
||||
|
||||
/**
|
||||
* 用户在商户appid下的唯一标识
|
||||
*/
|
||||
@XmlElement(name = "openid")
|
||||
@JSONField(name = "openid")
|
||||
private String openId;
|
||||
|
||||
public String getOpenId() {
|
||||
return openId;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "AuthCodeOpenIdResult [openId=" + openId + ", "
|
||||
+ super.toString() + "]";
|
||||
}
|
||||
}
|
||||
Loading…
x
Reference in New Issue
Block a user