标签:return 代码 res ring print 微信服务号 打包 异步 href
这一节我们将完成支付以及查询支付结果。
完成支付sdk的打包
https://www.jianshu.com/p/0b80e20c367c
<dependency>
<groupId>com.github.wxpay</groupId>
<artifactId>wxpay-sdk</artifactId>
<version>3.0.9</version>
</dependency>
import com.github.wxpay.sdk.IWXPayDomain;
import com.github.wxpay.sdk.WXPayConfig;
import java.io.InputStream;
public class MyConfig extends WXPayConfig {
public String getAppID() {
return "wx35757b8dde*****";
}
public String getMchID() {
return "15330*****";
}
public String getKey() {
return "yr0YOqr9sOJnK9Hpe9i7Gk2H7XO*****";
}
public InputStream getCertStream() {
return null;
}
public IWXPayDomain getWXPayDomain() {
return new IWXPayDomain() {
public void report(String domain, long elapsedTimeMillis, Exception ex) {
}
public DomainInfo getDomain(WXPayConfig config) {
return new DomainInfo("api.mch.weixin.qq.com", true);
}
};
}
}
import com.github.wxpay.sdk.MyConfig;
import com.github.wxpay.sdk.WXPay;
import java.util.HashMap;
import java.util.Map;
public class UnifiedorderTest {
public static void main(String[] args) throws Exception {
MyConfig config = new MyConfig();
WXPay wxpay = new WXPay(config);
Map<String, String> data = new HashMap<String, String>();
//商品简单描述
data.put("body", "class124测试");
//商户系统内部订单号,要求32个字符内,只能是数字、大小写字母_-|* 且在同一个商户号下唯一,这是询单,关单的唯一ID
data.put("out_trade_no", "2019102410595900000013");
//符合ISO 4217标准的三位字母代码,默认人民币:CNY
data.put("fee_type", "CNY");
//订单总金额,单位为分
data.put("total_fee", "1");
//支持IPV4和IPV6两种格式的IP地址。用户的客户端IP
data.put("spbill_create_ip", "192.168.100.192");
//异步接收微信支付结果通知的回调地址,通知url必须为外网可访问的url,不能携带参数,不是必须可以被访问。
data.put("notify_url", "http://47.106.177.33:8080/seller/toSellerCenter");
//JSAPI -JSAPI支付
//NATIVE -Native支付,此处指定为扫码支付
//APP -APP支付
data.put("trade_type", "NATIVE");
//trade_type=NATIVE时,此参数必传。此参数为二维码中包含的商品ID,商户自行定义
data.put("product_id", "12");
try {
Map<String, String> resp = wxpay.unifiedOrder(data);
System.out.println(resp);
} catch (Exception e) {
e.printStackTrace();
}
}
}
{
nonce_str=7XNlyZ1CeMJuBwBb,
code_url=weixin://wxpay/bizpayurl?pr=Nklt0xv,
appid=wx35757b8dde0f2a78,
sign=1D0EE7259E46681DC1E4363F7FEFB21EEF697E0F143B9FF42C1E131EF0A8D805,
trade_type=NATIVE,
return_msg=OK,
result_code=SUCCESS,
mch_id=1533074101,
return_code=SUCCESS, prepay_id=wx05185635134826b3e2984dd91472394600
}
import com.github.wxpay.sdk.MyConfig;
import com.github.wxpay.sdk.WXPay;
import java.util.HashMap;
import java.util.Map;
public class OrderqueryTest {
public static void main(String[] args) throws Exception {
MyConfig config = new MyConfig();
WXPay wxpay = new WXPay(config);
Map<String, String> data = new HashMap<String, String>();
data.put("out_trade_no", "2019102410595900000013");
try {
Map<String, String> resp = wxpay.orderQuery(data);
System.out.println(resp);
} catch (Exception e) {
e.printStackTrace();
}
}
}
{
nonce_str=CV3IA3O09mhDSXJr,
device_info=,
out_trade_no=2019102410595900000013,
trade_state=NOTPAY,
appid=wx35757b8dde0f2a78,
total_fee=1, sign=46B503160388E41DFDF8643922E23F005E491016F9C2CA658902710FD2969E8F,
trade_state_desc=订单未支付,
return_msg=OK,
result_code=SUCCESS,
mch_id=1533074101,
return_code=SUCCESS
}
由询单结果,我们可以看到“订单未支付”。下一节我们将把下单返回的code_url生成二维码,以便完成支付。
标签:return 代码 res ring print 微信服务号 打包 异步 href
原文地址:https://www.cnblogs.com/alichengxuyuan/p/12503538.html