微信扫码支付(模式二)

Java之微信支付(扫码支付模式二)案例实战 摘要:最近的一个项目中涉及到了支付业务,其中用到了微信支付和支付宝支付,在做的过程中也遇到些问题,所以现在总结梳理一下,分享给有需要的人,也为自己以后回顾留个思路。 一:微信支付接入准备工作: 首先,微信支付,只支持企业用户,个人用户是不能接入微信支付的,所以要想接入微信支付,首先需要有微信公众号,这个的企业才能申请。有了微信公众号,就能申请微信支付的相关内容,所以在准备开始写代码之前需要先把...... 阅读详情

用户扫描商户展示在各种场景的二维码进行支付。

微信提供两种扫码支付模式,模式一是先生成一个微信规定格式的二维码供用户扫描,引导完成支付,需要在服务号上配置回调地址。模式二通过后台向微信提交支付申请,微信提供一个连接,将连接生成二维码后供用户扫描完成支付。
官方解释:
【模式一】:商户后台系统根据微信支付规则链接生成二维码,链接中带固定参数productid(可定义为产品标识或订单号)。用户扫码后,微信支付系统将productid和用户唯一标识(openid)回调商户后台系统(需要设置支付回调URL),商户后台系统根据productid生成支付交易,最后微信支付系统发起用户支付流程。
【模式二】:商户后台系统调用微信支付【统一下单API】生成预付交易,将接口返回的链接生成二维码,用户扫码后输入密码完成支付交易。注意:该模式的预付单有效期为2小时,过期后无法支付。
本文采用模式二。(官方文档:https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_5)

这里写图片描述
业务流程说明:

(1)商户后台系统根据用户选购的商品生成订单。

(2)用户确认支付后调用微信支付【统一下单API】生成预支付交易;

(3)微信支付系统收到请求后生成预支付交易单,并返回交易会话的二维码链接code_url。

(4)商户后台系统根据返回的code_url生成二维码。

(5)用户打开微信“扫一扫”扫描二维码,微信客户端将扫码内容发送到微信支付系统。

(6)微信支付系统收到客户端请求,验证链接有效性后发起用户支付,要求用户授权。

(7)用户在微信客户端输入密码,确认支付后,微信客户端提交授权。

(8)微信支付系统根据用户授权完成支付交易。

(9)微信支付系统完成支付交易后给微信客户端返回交易结果,并将交易结果通过短信、微信消息提示用户。微信客户端展示支付交易结果页面。

(10)微信支付系统通过发送异步消息通知商户后台系统支付结果。商户后台系统需回复接收情况,通知微信后台系统不再发送该单的支付通知。

(11)未收到支付通知的情况,商户后台系统调用【查询订单API】。

(12)商户确认订单已支付后给用户发货。
具体代码:
action中代码:

/**
 * 微信支付的action
 * @author 
 * @since 20180504
 */
@Namespace("/QRpay")
public class WeChatPayAction extends BasicAction<DoctorAccount>{
    private static final long serialVersionUID = 1L;
    // 微信的参数
    private WeixinConfigUtils config = new WeixinConfigUtils();
    @Resource
    private IBasicsConfigService basicsConfigService;
    private Unifiedorder unifiedorder = new Unifiedorder();

    @Action("generateOrder")
    public String generateOrder(){
        String candy = Struts2Utils.getRequest().getParameter("candy");
            if (StringUtils.isNotBlank(candy)) {
            Integer score = Integer .valueOf(candy);
            String url = null;
            String out_trade_no = UuIdUtils.getUUID();
            //从redis中获取固定的连接地址
            String domainName = basicsConfigService.getBasicsConfig();
            // 参数组
            String appid = config.appid_doctor;
            String mch_id = config.mch_id_doctor;
            String nonce_str = RandCharsUtils.getRandomString(16);
            String body = "";
            body = "医师购买" + score + "康币,支付" + score + "元";
            String spbill_create_ip = "127.0.0.1";
            int total_fee = score;// 单位是分,现在按照ios传递过来的参数进行
            String notify_url = domainName+"/weixinPay/notifyDoctorUrl.do";
            String trade_type = "NATIVE";
            unifiedorder = WXSignUtils.getQRUnifiedorder(appid, mch_id, body, nonce_str, out_trade_no, total_fee, notify_url, trade_type, spbill_create_ip, "2");
            try {
                Map<String, String> map = HttpXmlUtils.getQRMap(unifiedorder);
                for (String value : map.keySet()) {
                    if (map.get("return_code").equals("SUCCESS")) {
                      url =  map.get("code_url");
                    }
                    System.out.println(value + map.get(value));
                }
            } catch (Exception e) {
                // TODO: handle exception
            }
         }

        return null;
    }
}

WeixinConfigUtils:

/**
 * 微信的配置参数
 * @author 
 * @date 2017/08/10
 */
@SuppressWarnings("unused")
public class WeixinConfigUtils {
    private static final Log log = LogFactory.getLog(WeixinConfigUtils.class);
    public static String appid;
    public static String mch_id;
    public static String mch_id_doctor;
    public static String appid_doctor;

    static {
        try{
            InputStream is = WeixinConfigUtils.class.getResourceAsStream("/weixin.properties");
            Properties properties = new Properties();
            properties.load(is);
            appid = properties.getProperty("weixin.appid");
            mch_id = properties.getProperty("weixin.mch_id");
            appid_doctor=properties.getProperty("weixin.doctor.appid");
            mch_id_doctor = properties.getProperty("weixin.doctor.mch_id");
        }catch(Exception ex){
            log.debug("加载配置文件:"+ex.getMessage());
        }
    }
}

Unifiedorder用于封装微信相关的请求字段:包括退款,扫码支付、app支付、h5支付、转账到个人

/**
 * 统一下单提交为微信的参数
 * @author 
 * @date 2017年08月11日
 */
public class Unifiedorder implements Serializable{
    private static final long serialVersionUID = 1L;
    //微信支付表id
    private Integer weixinId;
    //微信分配的公众账号ID(企业号corpid即为此appId)
    private String appid;
    //商户id
    private String mch_id;
    //终端设备号(门店号或收银设备ID),注意:PC网页或公众号内支付请传"WEB"
    private String device_info;
    //随机字符串:数字+大写字母的组合,32位
    private String nonce_str;
    //签名
    private String sign;
    //商品或支付单简要描述
    private String body;
    //商品名称明细列表
    private String detail;
    //附加参数(例如:用于区别本商户不同的分店)
    private String attach;
    //商户系统内部的订单号
    private String out_trade_no;
    //货币类型:符合ISO 4217标准的三位字母代码,默认人民币:CNY
    private String fee_type;
    //总金额
    private int total_fee;
    //APP和网页支付提交[用户端ip],Native支付填调用微信支付API的机器IP。
    private String spbill_create_ip;
    //订单生成时间,格式为yyyyMMddHHmmss,
    private String time_start;
    //订单失效时间,格式为yyyyMMddHHmmss,最短失效时间间隔必须大于5分钟[支付宝是30分钟,同样30分钟]
    private String time_expire;
    //商品标记,代金券或立减优惠功能的参数
    private String goods_tag;
    //接收微信支付异步通知回调地址
    private String notify_url;
    //交易类型:JSAPI,NATIVE,APP h5为 MWEB
    private String trade_type;
    //trade_type=NATIVE,此参数必传。此id为二维码中包含的商品ID,商户自行定义。
    private String product_id;
    //no_credit--指定不能使用信用卡支付
    private String limit_pay;
    //trade_type=JSAPI,此参数必传,用户在商户appid下的唯一标识
    private String openid;
    //商户内部自己的退款单号
    private String out_refund_no;
    //退款总金额单位为分
    private int refund_fee;
    //操作员的id默认为mch_id
    private String op_user_id;
    //微信官方提供的订单号
    private String prepayid;
    //记录所对应的member
    private Member member;
    //返回给微信的状态码(用于支付回调时)
    public String return_code;
    //微信h5支付时候的场景信息官方的信息模板 {"h5_info"://h5支付固定传"h5_info" 
    //{"type":"",//场景类型 "wap_url":"",//WAP网站URL地址"wap_name": ""//WAP 网站名}}
    public String scene_info;
    public String getScene_info() {
        return scene_info;
    }
    public void setScene_info(String scene_info) {
        this.scene_info = scene_info;
    }
    public String getReturn_code() {
        return return_code;
    }
    public void setReturn_code(String return_code) {
        this.return_code = return_code;
    }
    public String getAppid() {
        return appid;
    }
    public String getMch_id() {
        return mch_id;
    }
    public String getDevice_info() {
        return device_info;
    }
    public String getNonce_str() {
        return nonce_str;
    }
    public String getSign() {
        return sign;
    }
    public String getBody() {
        return body;
    }
    public String getDetail() {
        return detail;
    }
    public String getAttach() {
        return attach;
    }
    public String getOut_trade_no() {
        return out_trade_no;
    }
    public String getFee_type() {
        return fee_type;
    }
    public int getTotal_fee() {
        return total_fee;
    }
    public String getSpbill_create_ip() {
        return spbill_create_ip;
    }
    public String getTime_start() {
        return time_start;
    }
    public String getTime_expire() {
        return time_expire;
    }
    public String getGoods_tag() {
        return goods_tag;
    }
    public String getNotify_url() {
        return notify_url;
    }
    public String getTrade_type() {
        return trade_type;
    }
    public String getProduct_id() {
        return product_id;
    }
    public String getLimit_pay() {
        return limit_pay;
    }
    public String getOpenid() {
        return openid;
    }
    public void setAppid(String appid) {
        this.appid = appid;
    }
    public void setMch_id(String mch_id) {
        this.mch_id = mch_id;
    }
    public void setDevice_info(String device_info) {
        this.device_info = device_info;
    }
    public void setNonce_str(String nonce_str) {
        this.nonce_str = nonce_str;
    }
    public void setSign(String sign) {
        this.sign = sign;
    }
    public void setBody(String body) {
        this.body = body;
    }
    public void setDetail(String detail) {
        this.detail = detail;
    }
    public void setAttach(String attach) {
        this.attach = attach;
    }
    public void setOut_trade_no(String out_trade_no) {
        this.out_trade_no = out_trade_no;
    }
    public void setFee_type(String fee_type) {
        this.fee_type = fee_type;
    }
    public void setTotal_fee(int total_fee) {
        this.total_fee = total_fee;
    }
    public void setSpbill_create_ip(String spbill_create_ip) {
        this.spbill_create_ip = spbill_create_ip;
    }
    public void setTime_start(String time_start) {
        this.time_start = time_start;
    }
    public void setTime_expire(String time_expire) {
        this.time_expire = time_expire;
    }
    public void setGoods_tag(String goods_tag) {
        this.goods_tag = goods_tag;
    }
    public void setNotify_url(String notify_url) {
        this.notify_url = notify_url;
    }
    public void setTrade_type(String trade_type) {
        this.trade_type = trade_type;
    }
    public void setProduct_id(String product_id) {
        this.product_id = product_id;
    }
    public void setLimit_pay(String limit_pay) {
        this.limit_pay = limit_pay;
    }
    public void setOpenid(String openid) {
        this.openid = openid;
    }
    public String getOut_refund_no() {
        return out_refund_no;
    }
    public void setOut_refund_no(String out_refund_no) {
        this.out_refund_no = out_refund_no;
    }
    public int getRefund_fee() {
        return refund_fee;
    }
    public void setRefund_fee(int refund_fee) {
        this.refund_fee = refund_fee;
    }
    public Integer getWeixinId() {
        return weixinId;
    }
    public void setWeixinId(Integer weixinId) {
        this.weixinId = weixinId;
    }
    public Member getMember() {
        return member;
    }
    public void setMember(Member member) {
        this.member = member;
    }
    public String getPrepayid() {
        return prepayid;
    }
    public void setPrepayid(String prepayid) {
        this.prepayid = prepayid;
    }
    public String getOp_user_id() {
        return op_user_id;
    }
    public void setOp_user_id(String op_user_id) {
        this.op_user_id = op_user_id;
    }
    }

UuIdUtils代码:

public class UuIdUtils {
    public static String getUUID() {
        return UUID.randomUUID().toString().replace("-", "");
    }
}

RandCharsUtils代码:

/**
 * nonce_str随即字符串
* @author 
 * @date 2017/08/10
 */
public class RandCharsUtils {
    private static SimpleDateFormat df = new SimpleDateFormat("yyyyMMddHHmmss");

    public static String getRandomString(int length) { //length表示生成字符串的长度
        String base = "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789abcdefghijklmnopqrstuvwxyz";   
        Random random = new Random();   
        StringBuffer sb = new StringBuffer();
        int number = 0;
        for (int i = 0; i < length; i++) {   
            number = random.nextInt(base.length());   
            sb.append(base.charAt(number));   
        }   
        return sb.toString();   
    }   

    /*
     * 订单开始交易的时间
     */
    public static String timeStart(){
        return df.format(new Date());
    }

    /*
     * 订单开始交易的时间
     */
    public static String timeExpire(){
        Calendar now=Calendar.getInstance();
        now.add(Calendar.MINUTE,30);
        return df.format(now.getTimeInMillis());
    }

}

WXSignUtils代码

/**
 * 微信支付签名
 * @author 
 * @date 2017/08/10
 */
public class WXSignUtils {
    //微信统一签名的对象 
    private static Unifiedorder unifiedorder = new Unifiedorder();
    //封装参数的方法
    private static SortedMap<Object, Object> parameters = new TreeMap<Object, Object>();
    /**
     * 微信支付签名算法sign
     * @param characterEncoding
     * @param parameters
     * @return
     */
    @SuppressWarnings("rawtypes")
    public static String createSign(String characterEncoding,SortedMap<Object,Object> parameters,String type){
        StringBuffer sb = new StringBuffer();
        Set es = parameters.entrySet();//所有参与传参的参数按照accsii排序(升序)
        Iterator it = es.iterator();
        while(it.hasNext()) {
            Map.Entry entry = (Map.Entry)it.next();
            String k = (String)entry.getKey();
            Object v = entry.getValue();
            if(null != v && !"".equals(v) 
                    && !"sign".equals(k) && !"key".equals(k)) {
        sb.append(k + "=" + v + "&");
            }
        }
        if (type.equals("1")) {
            sb.append("key=" + weixinConstant.KEY);
        }else if (type.equals("2")) {
            sb.append("key=" + weixinConstant.DOC_KEY);
        }
        String sign = MD5Util.MD5Encode(sb.toString(), characterEncoding).toUpperCase();
        return sign;
    }


     /**
     * 微信扫码支付时返回封装好的参数
     * @author yangfuren
     * @param appid  应用id
     * @param mch_id 商户号
     * @param body 内容
     * @param nonce_str 随机串
     * @param out_trade_no  微信商户号
     * @param total_fee 总价格
     * @param notify_url 回调url 
     * @param trade_type 支付方式
     * @param spbill_create_ip 请求接口id
     * @param scence_info h5支付相关信息
     * @param type 1用户  2 医师
     * @return
     */
    public static Unifiedorder getQRUnifiedorder(String appid,String mch_id,String body,String nonce_str,String out_trade_no,Integer total_fee,String notify_url,String trade_type,String spbill_create_ip,String type)
    {
        parameters.put("appid", appid);
        parameters.put("mch_id", mch_id);
        parameters.put("body", body);
        parameters.put("nonce_str", nonce_str);
        parameters.put("out_trade_no", out_trade_no);
        parameters.put("total_fee", total_fee);
        parameters.put("notify_url", notify_url);
        parameters.put("trade_type", trade_type);
        parameters.put("spbill_create_ip", spbill_create_ip);
        String sign = createSign("UTF-8", parameters,type);
        // 微信统一下单
        unifiedorder.setAppid(appid);
        unifiedorder.setMch_id(mch_id);
        unifiedorder.setNonce_str(nonce_str);
        unifiedorder.setSign(sign);
        unifiedorder.setBody(body);
        unifiedorder.setOut_trade_no(out_trade_no);
        unifiedorder.setTotal_fee(total_fee);
        unifiedorder.setSpbill_create_ip(spbill_create_ip);
        unifiedorder.setNotify_url(notify_url);
        unifiedorder.setTrade_type(trade_type);
        return unifiedorder;
    }
}

MD5:

public class MD5Util {

    private static String byteArrayToHexString(byte b[]) {
        StringBuffer resultSb = new StringBuffer();
        for (int i = 0; i < b.length; i++)
            resultSb.append(byteToHexString(b[i]));

        return resultSb.toString();
    }

    private static String byteToHexString(byte b) {
        int n = b;
        if (n < 0)
            n += 256;
        int d1 = n / 16;
        int d2 = n % 16;
        return hexDigits[d1] + hexDigits[d2];
    }

    public static String MD5Encode(String origin, String charsetname) {
        String resultString = null;
        try {
            resultString = new String(origin);
            MessageDigest md = MessageDigest.getInstance("MD5");
            if (charsetname == null || "".equals(charsetname))
                resultString = byteArrayToHexString(md.digest(resultString
                        .getBytes()));
            else
                resultString = byteArrayToHexString(md.digest(resultString
                        .getBytes(charsetname)));
        } catch (Exception exception) {
        }
        return resultString;
    }

    private static final String hexDigits[] = { "0", "1", "2", "3", "4", "5",
        "6", "7", "8", "9", "a", "b", "c", "d", "e", "f" };

}

请求参数并解析返回xml:


    /**
     * 构造xml参数
     * @param xml
     * @return
     */
    public static String QRxmlInfo(Unifiedorder unifiedorder){

        if(unifiedorder!=null){
            StringBuffer bf = new StringBuffer();
            bf.append("<xml>");

            bf.append("<appid><![CDATA[");
            bf.append(unifiedorder.getAppid());
            bf.append("]]></appid>");

            bf.append("<mch_id><![CDATA[");
            bf.append(unifiedorder.getMch_id());
            bf.append("]]></mch_id>");

            bf.append("<nonce_str><![CDATA[");
            bf.append(unifiedorder.getNonce_str());
            bf.append("]]></nonce_str>");

            bf.append("<sign><![CDATA[");
            bf.append(unifiedorder.getSign());
            bf.append("]]></sign>");

            bf.append("<body><![CDATA[");
            bf.append(unifiedorder.getBody());
            bf.append("]]></body>");

            bf.append("<out_trade_no><![CDATA[");
            bf.append(unifiedorder.getOut_trade_no());
            bf.append("]]></out_trade_no>");

            bf.append("<total_fee><![CDATA[");
            bf.append(unifiedorder.getTotal_fee());
            bf.append("]]></total_fee>");

            bf.append("<spbill_create_ip><![CDATA[");
            bf.append(unifiedorder.getSpbill_create_ip());
            bf.append("]]></spbill_create_ip>");

            bf.append("<notify_url><![CDATA[");
            bf.append(unifiedorder.getNotify_url());
            bf.append("]]></notify_url>");

            bf.append("<trade_type><![CDATA[");
            bf.append(unifiedorder.getTrade_type());
            bf.append("]]></trade_type>");

            bf.append("</xml>");
            return bf.toString();
        }
        return "";
    }

    /**
     * post请求并得到返回结果
     * @param requestUrl
     * @param requestMethod
     * @param output
     * @return
     */
    public static String httpsRequest(String requestUrl, String requestMethod, String output) {
        try{
            URL url = new URL(requestUrl);
            HttpsURLConnection connection = (HttpsURLConnection) url.openConnection();
            connection.setDoOutput(true);
            connection.setDoInput(true);
            connection.setUseCaches(false);
            connection.setRequestMethod(requestMethod);
            if (null != output) {
                OutputStream outputStream = connection.getOutputStream();
                outputStream.write(output.getBytes("UTF-8"));
                outputStream.close();
            }
            // 从输入流读取返回内容
            InputStream inputStream = connection.getInputStream();
            InputStreamReader inputStreamReader = new InputStreamReader(inputStream, "utf-8");
            BufferedReader bufferedReader = new BufferedReader(inputStreamReader);
            String str = null;
            StringBuffer buffer = new StringBuffer();
            while ((str = bufferedReader.readLine()) != null) {
                buffer.append(str);
            }
            bufferedReader.close();
            inputStreamReader.close();
            inputStream.close();
            inputStream = null;
            connection.disconnect();
            return buffer.toString();
        }catch(Exception ex){
            ex.printStackTrace();
        }
        return "";
    }

    /**
     * h5支付时 解析返回的值并返回prepareid
     * @throws IOException 
     * @throws JDOMException 
     */
    public static Map<String, String> getQRMap(Unifiedorder unifiedorder) throws JDOMException, IOException{
        String xmlInfo = QRxmlInfo(unifiedorder);
        String wxUrl = weixinConstant.URL;
        String method = "POST";
        String weixinPost = HttpXmlUtils.httpsRequest(wxUrl, method, xmlInfo).toString();
        ParseXMLUtils.jdomParseXml(weixinPost);
        StringReader read = new StringReader(weixinPost);
        // 创建新的输入源SAX 解析器将使用 InputSource 对象来确定如何读取 XML 输入
        InputSource source = new InputSource(read);
        // 创建一个新的SAXBuilder
        SAXBuilder sb = new SAXBuilder();
        // 通过输入源构造一个Document
        org.jdom.Document doc;
        doc = (org.jdom.Document) sb.build(source);
        org.jdom.Element root = doc.getRootElement();// 指向根节点
        List<org.jdom.Element> list = root.getChildren();
        Map<String, String> msg = new HashMap<String, String>();
        if(list!=null&&list.size()>0){
            for (org.jdom.Element element : list) {
            msg.put(element.getName(), element.getText());
            }
            }
        return msg;
    }
微信扫码支付总结-PC端-Java(模式二) 前言 最近做的项目有对接微信支付的需求,于是开始了一个人的摸索。本文的前提是公司已经申请了商户号和appid,设置了商户号对应的key,即appId,mchId,key三个参数。以下为开发步骤: 1 阅读微信官方开发文档 微信官方文档链接:https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_1 这里选择流程更为简单的模式二... 阅读详情

相关推荐

Java实现微信扫码支付模式二功能及回调处理

微信扫码支付模式二提供了一种便捷且安全的支付方式,用户仅需扫描商家提供的二维码即可完成支付,极大地提升了交易效率。与传统的支付模式相比,扫码支付模式二在用户交互流程上进行了优化,通过以下三个核心步骤实现整个支付过程:预支付交易请求的生成:在交易发起前,商家端会向微信支付服务器发送预支付请求,该请求包含了支付金额、商品描述等必要的交易信息。二维码的生成:微信支付服务器接收到预支付请求后,生成一个支付二维码,并将该二维码返回给商家端。用户扫码支付。

weixin_42577735的博客 1267

微信支付宝支付经验以及相关坑

此片文章介绍对接微信、支付宝所遇到的问题以及经验之谈。 准备工作 支付类型 文档 对接难易程度 文档地址 支付宝 文档写的不错 易 https://docs.open.alipay.com/api_1/alipay.trade.fastpay.refund.query 微信 不想说了 难(也不能说难应该是坑) https://pay.weixin.qq.com/wiki/doc/api/app/app.php?chapter=8_1 熟悉支付流程 支付宝 微信 有萝卜有坑 .

u012423347的专栏 505

Delphi 7实现微信扫码支付模式二及统一订单流程

简介:本文详细介绍了如何在Delphi 7环境下实现微信扫码支付的“模式二”功能,包括统一下单过程。文章首先介绍了Delphi 7环境的准备,然后深入探讨了微信支付SDK的集成,扫码支付流程的详细步骤,以及统一下单接口的参数配置。此外,文章还涉及了请求签名与响应验证的方法,处理支付结果的重要性,以及用户界面设计的实现。

weixin_42576410的博客 1203

网页微信扫码支付

随着网上支付的形式越来越多,为各种网上支付项目,特意总结微信扫码支付,两种模式 C#版SDK下载链接https://pay.weixin.qq.com/wiki/doc/api/download/WxPayAPI_CS_v3.zip 模式一开发前,商户必须在公众平台后台设置支付回调URL。URL实现的功能:接收用户扫码后微信支付系统回调的productid和openid;URL设置详见

yuanll023的博客 8782

基于thinkphp5和微信扫码支付模式2

基于thinkphp5和微信扫码支付模式2

专有钉钉小程序(浙政钉)开发搭建流程总览

最近公司有一个项目要做浙政钉,让我来负责做。靠,我一脸懵,开发了两年多不知道浙政钉是啥,感觉我眼界还是低了。然后就去百度、同事问了一圈才知道就是个钉钉小程序嘛,然后发布到浙政钉上了。就搭建项目跑起来我都肥了很多事,中间走了很多坑。正好领导让我写《钉钉小程序前端开发流程》,这想着也写个博客吧。下面就是整个流程及我所遇到的坑!

m0_53910290的博客 6356

微信扫码支付模式二小结

1. 准备工作微信公众平台配置appid;商户平台配置:MCH_ID ,api_key,和notify_url(微信支付的支付结果 异步回调地址);2. 生成订单,调用微信统一下单接口//统一下单接口地址public static String UFDODER_URL = "https://api.mch.weixin.qq.com/pay/unifiedorder";/***这是统一...

qq_40249994的博客 1893

奈曼-皮尔逊准则

奈曼-皮尔逊准则 如果各个假设的先验概率P(Hi)(i=0,1)P(H_i)(i=0,1)P(Hi​)(i=0,1)已知,并且每种判决的代价函数已知,这时,可以用贝叶斯准则进行判决。 如果进一步假设正确判决不付出的代价,而错误判决代价相同,即c00=c11=0,c01=c10=1c_{00}=c_{11}=0,c_{01}=c_{10}=1c00​=c11​=0,c01​=c10​=1,这时可以用最小平均错误概率准则进行判决。 在不知道先验概率P(Hi)(i=0,1)P(H_i)(i=0,1)P(Hi​)(

little_soldier的专栏 1万+

微信 扫码支付模式二 开发

微信扫码支付的开发

追风少年的博客 2012

常微分方程 (ODE) 和 随机微分方程 (SDE)

常微分方程(Ordinary Differential Equations, ODE)和随机微分方程(Stochastic Differential Equations, SDE)是数学中描述系统动态行为的重要工具。它们有一些相似之处,但在处理随机性方面存在显著差异。

weixin_39699362的博客 4384

【推荐100个unity插件】性能极高的逼真爆炸、火焰和烟雾效果——UNI VFX

这是一篇关于Unity中高性能GPU粒子特效插件UNI VFX的使用指南。文章介绍了该插件提供逼真的爆炸、火焰和烟雾效果,支持URP和HDRP渲染管线。主要内容包括:插件安装方法(需预先安装Visual Effect Graph和Shader Graph包)、事件系统使用方法(如create/loop/stop等事件控制)、特效分类(自动结束型和持续型特效)、检视面板配置技巧以及性能优化建议(特别提醒灯光特效对性能的影响较大)。文末还推荐了多个Unity开发相关的专栏内容。

向宇的博客,专注php/web全栈 unity游戏开发,欢迎大家评论纠错 1492

JAVA微信扫码支付模式二功能实现以及回调

关于准备工作,就“微信扫码支付模式二”官方文档地址在这https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=9_1 对于“微信扫码支付模式二”(支付与回调)实际只会用到APP_ID、MCH_ID和API_KEY,其他的都不用。 自己用springBoot搭建一个简单的web项目,把下面代码放在项目里跑就行了,不需要额外的jar包。由于是...

weixin_43229729的博客 707

YOLOv11改进 | 损失函数篇 | YOLOv11引入引MPDIoU, GIoU,DIoU, CIoU, SIoU,EIoU, WIoU, LMPDIoU等损失函数

到此本文的正式分享内容就结束了,在这里给大家推荐我的YOLOv11改进有效涨点专栏,本专栏目前为新开的,后期我会根据各种前沿顶会进行论文复现,也会对一些老的改进机制进行补充,如果大家觉得本文帮助到你了,订阅本专栏,关注后续更多的更新~1. YOLOv11中添加MPDIoU, GIoU,DIoU, CIoU, SIoU等损失函数的方式。文件中用给出的代码替换掉。

tsg6698的博客 5280

JAVA微信扫码支付模式二功能实现完整例子

本例子实现微信扫码支付模式二的支付功能,应用场景是,web网站微信扫码支付。实现从点击付费按钮、到弹出二维码、到用户用手机微信扫码支付、到手机上用户付费成功、web网页再自动调整到支付成功后的页面,这一个过程。 代码下载:http://www.demodashi.com/demo/10268.html

findhappy117的博客 1083

SPICE仿真软件:HSPICE_(22).HSPICE仿真案例分析

通过上述案例分析,我们可以看到HSPICE仿真软件在不同电路类型和仿真场景中的应用。无论是简单的直流分析、交流分析还是复杂的暂态分析,HSPICE都能提供详细的仿真结果,帮助我们更好地理解和优化电路设计。希望这些案例能够为读者提供实用的参考和指导,进一步提升使用HSPICE进行电路仿真的能力。输入文件的编写:确保输入文件格式正确,使用注释来解释每一部分的内容。分析类型的选择:根据电路的特点选择合适的分析类型,如.DC.AC和.TRAN。输出结果的设置:使用.print命令来指定需要输出的节点电压和支路电流。

kkchenjj的博客 1309

使用 Tesseract 在 C# 中进行光学字符识别(OCR)

你可以根据需要对 Tesseract 进行自定义配置,例如设置识别的分辨率、识别模式等。// 只识别数字// 设置自定义变量本文只讲述了简单的使用方法,未涉及字库训练,识别的准确率与训练的字库有关。

仰望星空的博客 4734

Java-微信扫码支付功能模式二实战案例

在网上找了很久的微信扫码支付模式二的案例,发现很多要么都是代码不全,要么就是代码错误的

qq_44614878的博客 590

AI上推荐 之 隐语义模型(LFM)和矩阵分解(MF)

1. 前言 随着信息技术和互联网的发展, 我们已经步入了一个信息过载的时代,这个时代,无论是信息消费者还是信息生产者都遇到了很大的挑战: 信息消费者:如何从大量的信息中找到自己感兴趣的信息? 信息生产者:如何让自己生产的信息脱颖而出, 受到广大用户的关注? 为了解决这个矛盾, 推荐系统应时而生, 并飞速前进,在用户和信息之间架起了一道桥梁,一方面帮助用户发现对自己有价值的信息, 一方面让信息能够展现在对它感兴趣的用户前面。 推荐系统近几年有了深度学习的助推发展之势迅猛, 从前深度学习的传统推荐模型(协

Miracle8070 1万+

微信支付扫码支付(模式二)

微信支付扫码支付(模式二)的支付流程是:生成订单 ,统一下单,统一下单后返回code_url,根据code_url 生成一个支付二维码,然后是支付回调。流程大体是这样的。给个文档地址:https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=6_5 前端界面 index.html,先预下单返回code_url 然后把code_url 去...

qq_37655169的博客 385

WINCC7.3破解文件

WINCC7.3硬件够破解文件,有需要的下载!WINCC7.3硬件够破解文件,有需要的下载!

win10 跳过U8环境检测的IE WebControls.rar

win10 安装u8的时候 提示IE WebControls 不通过,这个工具可以欺骗u8的检查。 跳过U8环境检测的IE WebControls。提示导入失败后,重新检测通过。

ThinkPHP整合微信支付之Native 扫码支付 模式二

大家好,这篇文章是继微信支付之Native 扫码支付 模式一之后的微信支付系列教程第三篇:扫码支付之模式二 介绍下扫码支付目前有两种模式,模式一比模式二稍微复杂点,至于模式一与模式二的具体内容,流程,微信开发文档都有详细介绍,这里就不多说废话,接下来赶紧上教程! demo下载地址:https://github.com/1290800466/mac_win/tree/master/weixin_

wml 4233

廖雪峰Python教程[完整版]

廖雪峰的python教程整理的,已经排好版了,而且还是完整的,适合小白

微信扫码支付模式二的坑

笔记:在做微信扫码支付的时候,模式一比较复杂,需要在公众平台后台设置支付回调url,模式二是不用设置,也就造成了模式二没有返回支付状态的,那么如何解决用户支付页面提示这个功能呢?1、采用页面刷新,定时器去刷新订单交易结果2、采用websocket推送给页面信息模式一开发前,商户必须在公众平台后台设置支付回调URL。URL实现的功能:接收用户扫码后微信支付系统回调的productid和openid;...

zhejingyuan的专栏 7712

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

.NET微信扫码支付模式二API接口开发测试

.NET微信扫码支付模式二API接口开发测试 主要实现微信扫码支付,官网的SDKdemo 就不要使用 一直不能调试通过的,还是自己按照API接口文档一步一步来实现,吐槽下微信一点责任感都木有,能不能demo搞个正常的吗,不要坑惨了一大群码农们有点社会责任感吧 还是多学学你的Alibaba 直接上干货 具体文档接口都直接参考文档说明干 具体代码一步一步呈上 Index.aspx 显示二维码页...

July_lulu的博客 1118

微信扫码支付模式一和模式二有何区别?

微信扫码支付有两种不同的模式: 模式一流程流程图 模式二流程流程图 通过两种模式的流程图分析:二者之间使用的场景不同,其最根本的区别就是扫码的时候是否订单已经生成。 模式一是适用于商超实体店的付款二维码, 而模式二是适用于网页订单付款二维码。 ...

༺࿈无关痛痒࿈༻的博客 677

thinkphp3.2.3 微信PC扫码支付 模式二

这篇文章主要介绍扫码支付场景二。 目前有两种模式,模式一比模式二稍微复杂点,至于模式一与模式二的具体内容,流程,微信开发文档都有详细介绍,这里就不多说废话,接下来赶紧上教程! 下载SDK类文件 Wxpay Library 并SDK文件/lib下的几个文件放置到/ThinkPHP/Library/Vendor/ 修改WxPay.pub.config.php中的配置选项 //===...

weixin_38615720的博客 1156
上一篇: JedisCluster连接redis集群(有密码)
下一篇: jsp判断集合不为空
蓝色格子
博客等级 码龄9年 129粉丝 174原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值