微信支付之PC网站(Native)支付详解

微信支付之native支付 微信支付, tenpay包的使用,tenpay包简介,tenpay的安装及使用,native支付 阅读详情
了解支付模式
Native

在这里插入图片描述
在这里插入图片描述

适用场景:

Native支付是指商户系统按微信支付协议生成支付二维码,用户再用微信“扫一扫”完成支付的模式。该模式适用于PC网站、实体店单品或订单、媒体广告支付等场景。

解释:
  • 这里描述一下PC端业务场景,例如:你在网站上购买东西,选择好商品后,会生成一个支付二维码,扫码支付后,商品的库存就减少了。 还有,自动贩卖机,选择商品后会生成支付二维码,扫码支付后,商品就会掉下来。
开发前准备
  • 申请认证公众号 (若已有公众号则可跳过, 注意: 1. 公众号类型需要为服务号或者订阅号 2. 公众号需要认证, 认证费用300RMB)点此跳转申请公众号
  • 申请网站备案 (若网站已备案则可跳过,注意:网站的备案内容需要和所出售商品直接关系)
  • 有以上两个条件后可以开始申请开通微信支付,具体的申请流程公众号平台都有,读者可自行去查阅。
  • 注意:1.开通微信支付需要公司账户打款验证,要及时和财务沟通好,查看公司流水。2.开通成功后,会收到邮件 ,邮件中的信息特别重要:示例如下在这里插入图片描述
    在这里插入图片描述
  • 以上三条均申请完成即可开始配置开发环境。拿到邮件中的信息后,按照邮件中的指引配置好相关信息之后就可以开始开发了。
    注意:很重要的几个信息,
      1. API证书
      1. API密钥
      1. APPID
开发工具:本文采用的是idea,其他IDE开发工具均可
环境准备:
添加依赖
		<!-- 添加微信支付jar包 -->
		<dependency>
			<groupId>com.github.wxpay</groupId>
			<artifactId>wxpay-sdk</artifactId>
			<version>0.0.3</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/dom4j/dom4j -->
		<dependency>
			<groupId>dom4j</groupId>
			<artifactId>dom4j</artifactId>
			<version>1.6.1</version>
		</dependency>
		<!-- 二维码生成依赖 -->
		<!-- 二维码 -->
		<!-- https://mvnrepository.com/artifact/com.google.zxing/core -->
		<dependency>
			<groupId>com.google.zxing</groupId>
			<artifactId>core</artifactId>
			<version>2.1</version>
		</dependency>
		<!-- https://mvnrepository.com/artifact/com.google.zxing/javase -->
		<dependency>
			<groupId>com.google.zxing</groupId>
			<artifactId>javase</artifactId>
			<version>2.1</version>
		</dependency>
示例代码目录

在这里插入图片描述

支付:
	/**
	 * 映射微信支付
	 *
	 * @param amount  金额(单位:分)
	 * @return
	 */
	@RequestMapping("/wxpay")
	public void wxPay(Integer amount,HttpServletResponse response) throws Exception {
		// 金额
		Double total_fee = amount.doubleValue();
		// 生成商家订单号
		String orderId = PayUtil.createOrder();
		if (total_fee > 0) {
			WXPayService wxPayService = WXPayService.getInstance(certPath, notifyUrl);
			String codeUrl = wxPayService.doUnifiedOrder(orderId, "收银台名称", total_fee, "产品id");

			//  ---------- 订单保存到数据库 ----------
			// 这里写你自己的订单保存逻辑
			// BizOrder bizOrder = new BizOrder();
			// bizOrder.setAmount(amount);
			// bizOrder.setAppid(PayConstant.APPID);
			// bizOrder.setMacId(orderId);
			// bizOrder.setTotalFee(String.valueOf(total_fee));
			// bizOrder.setOrgId(Long.parseLong(orgId));
			// BizOrder bo = bizOrderService.insertOrder(bizOrder);
			// if (bo == null)
			//	throw new NullPointerException("Don't save order!");

			// 生成支付二维码(数据流) 返回给前端页面
			QRCodeUtil.createQrCodeStream(codeUrl,900,"JPEG",response);
		}

	}
  • 支付业务
   /**
 * 微信支付业务
 * Created by Jason on 2018/11/20.
 */
public class WXPayService {
    private static Logger logger = LoggerFactory.getLogger(WXPayService.class);
    private WXPay wxpay;
    private WXPayConfigImpl config;
    private static WXPayService wxPayService;

    private WXPayService(String certPath, String notifyUrl) throws Exception {
        config = WXPayConfigImpl.getInstance(certPath,notifyUrl);
        wxpay = new WXPay(config);
    }

    public static WXPayService getInstance(String certPath,String notifyUrl) throws Exception {
        if (wxPayService == null) {
            synchronized (WXPayConfigImpl.class) {
                if (wxPayService == null) {
                    wxPayService = new WXPayService(certPath,notifyUrl);
                }
            }
        }
        return wxPayService;
    }

    /**
     * 微信下单接口
     *
     * @param out_trade_no 订单号
     * @param body         商家商品名
     * @param money        总金额
     * @param applyNo      商品编号
     * @return
     */
    public String doUnifiedOrder(String out_trade_no, String body, Double money, String applyNo) {
        String amt = String.valueOf(money * 100);
        HashMap<String, String> data = new HashMap<String, String>();
        data.put("body", body);
        data.put("out_trade_no", out_trade_no);
        data.put("device_info", "web");
        data.put("fee_type", "CNY");
        data.put("total_fee", amt.substring(0, amt.lastIndexOf(".")));
        data.put("spbill_create_ip", config.getSpbillCreateIp());
        data.put("notify_url", config.getNotifyUrl());
        data.put("trade_type", config.getTradeType());
        data.put("product_id", applyNo);
        System.out.println(String.valueOf(money * 100));
        // data.put("time_expire", "20170112104120");

        try {
            Map<String, String> r = wxpay.unifiedOrder(data);
            logger.info("返回的参数是" + r);
            return r.get("code_url");
        } catch (Exception e) {
            e.printStackTrace();
            logger.info(e.getMessage());
            return null;
        }
    }

    /**
     * 退款
     */
    public void doRefund(String out_trade_no, String total_fee) {
        logger.info("退款时的订单号为:" + out_trade_no + "退款时的金额为:" + total_fee);
        String amt = String.valueOf(Double.parseDouble(total_fee) * 100);
        logger.info("修正后的金额为:" + amt);
        logger.info("最终的金额为:" + amt.substring(0, amt.lastIndexOf(".")));
        HashMap<String, String> data = new HashMap<String, String>();
        data.put("out_trade_no", out_trade_no);
        data.put("out_refund_no", out_trade_no);
        data.put("total_fee", amt.substring(0, amt.lastIndexOf(".")));
        data.put("refund_fee", amt.substring(0, amt.lastIndexOf(".")));
        data.put("refund_fee_type", "CNY");
        data.put("op_user_id", config.getMchID());

        try {
            Map<String, String> r = wxpay.refund(data);
            logger.info("退款操作返回的参数为" + r);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }


    /**
     * 微信验签接口
     *
     * @return
     * @throws DocumentException
     */
    public boolean checkSign(String  strXML) throws DocumentException {
        SortedMap<String, String> smap = new TreeMap<String, String>();
        Document doc = DocumentHelper.parseText(strXML);
        Element root = doc.getRootElement();
        for (Iterator iterator = root.elementIterator(); iterator.hasNext();) {
            Element e = (Element) iterator.next();
            smap.put(e.getName(), e.getText());
        }
        return isWechatSign(smap,config.getKey());
    }


    private boolean isWechatSign(SortedMap<String, String> smap,String apiKey) {
        StringBuffer sb = new StringBuffer();
        Set<Entry<String, String>> es = smap.entrySet();
        Iterator<Entry<String, String>> it = es.iterator();
        while (it.hasNext()) {
            Entry<String, String> entry =  it.next();
            String k = (String) entry.getKey();
            String v = (String) entry.getValue();
            if (!"sign".equals(k) && null != v && !"".equals(v) && !"key".equals(k)) {
                sb.append(k + "=" + v + "&");
            }
        }
        sb.append("key=" + apiKey);
        /** 验证的签名 */
        String sign = MD5Util.MD5Encode(sb.toString(), "utf-8").toUpperCase();
        /** 微信端返回的合法签名 */
        String validSign = ((String) smap.get("sign")).toUpperCase();
        return validSign.equals(sign);
    }
}
  • 支付回调
/**
	 * 微信支付成功回调接口
	 *
	 * @param map      返回给页面
	 * @param request  接收请求
	 * @param response 响应
	 * @return
	 * @throws Exception
	 */
	@RequestMapping("/callback")
	public void callback(Map<String, Object> map, HttpServletRequest request,
						   HttpServletResponse response) throws Exception {

		log.info("用户支付成功,回调!");
		String inputLine;
		String notityXml = "";
		request.setCharacterEncoding("UTF-8");
		response.setCharacterEncoding("UTF-8");
		response.setContentType("text/html;charset=UTF-8");
		response.setHeader("Access-Control-Allow-Origin", "*");
		// 微信给返回的东西
		try {
			while ((inputLine = request.getReader().readLine()) != null) {
				notityXml += inputLine;
			}
			request.getReader().close();
		} catch (Exception e) {
			e.printStackTrace();
			log.info("xml获取失败");
			response.getWriter().write(setXml("FAIL", "xml获取失败"));
		}
		if (StringUtils.isEmpty(notityXml)) {
			log.info("xml为空");
			response.getWriter().write(setXml("FAIL", "xml为空"));
		}

		WXPayService wxService = WXPayService.getInstance(certPath, notifyUrl);
		if (!wxService.checkSign(notityXml)) {
			response.getWriter().write(setXml("FAIL", "验签失败"));
		}
		log.info("xml的值为:" + notityXml);
		Map<String, String> xmlMap = WXPayUtil.xmlToMap(notityXml); // 解析成map
		String json = JSON.toJSONString(xmlMap); // map 转成json
		log.info(json);
		JSONObject jsonObject = JSONObject.fromObject(json);
		UnifiedOrderRespose returnPay = (UnifiedOrderRespose) JSONObject.toBean(jsonObject, UnifiedOrderRespose.class);
		log.info(("转换后对象为:" + returnPay.toString()));
		log.info(("订单号:" + returnPay.getOut_trade_no() + "总金额:" + returnPay.getTotal_fee()));
		if (returnPay.getReturn_code().equals("SUCCESS") && returnPay.getOut_trade_no() != null
				&& !returnPay.getOut_trade_no().isEmpty()) {
			double fee = Double.parseDouble(returnPay.getTotal_fee());
			returnPay.setTotal_fee(String.valueOf(fee / 100));
			log.info("微信的支付状态为SUCCESS");
			// 支付成功业务
			synchronized (WXPayController.class) { // 加入同步锁
				Thread.sleep(1000); //睡一秒,防止并发倒致数据不一致
//				addServiceCount(returnPay,response); // 写你支付成功后的业务, 比如给用户充值服务次数
			}
			// 返回false的原因有可能是:订单已完成支付,或者订单已退款
		}else
			response.getWriter().write(setXml("FAIL","ORDER IS FINISH"));

		}
  • 二维码生成
/**
	 * 创建二维码输入流
	 * @param content		二维码内容
	 * @param qrCodeSize	二维码尺寸
	 * @param imageFormat	图片格式
	 * @param response		响应给页面
	 */
	public static void createQrCodeStream(String content, int qrCodeSize, String imageFormat, HttpServletResponse response) throws IOException, WriterException {
		//设置二维码纠错级别MAP
		Hashtable<EncodeHintType, ErrorCorrectionLevel> hintMap = new Hashtable<EncodeHintType, ErrorCorrectionLevel>();
		hintMap.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.L);  // 矫错级别
		QRCodeWriter qrCodeWriter = new QRCodeWriter();
		//创建比特矩阵(位矩阵)的QR码编码的字符串
		BitMatrix byteMatrix = qrCodeWriter.encode(content, BarcodeFormat.QR_CODE, qrCodeSize, qrCodeSize, hintMap);
		// 使BufferedImage勾画QRCode  (matrixWidth 是行二维码像素点)
		int matrixWidth = byteMatrix.getWidth();
		BufferedImage image = new BufferedImage(matrixWidth-200, matrixWidth-200, BufferedImage.TYPE_INT_RGB);
		image.createGraphics();
		Graphics2D graphics = (Graphics2D) image.getGraphics();
		graphics.setColor(Color.WHITE);
		graphics.fillRect(0, 0, matrixWidth, matrixWidth);
		// 使用比特矩阵画并保存图像
		graphics.setColor(Color.BLACK);
		for (int i = 0; i < matrixWidth; i++){
			for (int j = 0; j < matrixWidth; j++){
				if (byteMatrix.get(i, j)){
					graphics.fillRect(i-100, j-100, 1, 1);
				}
			}
		}
		// 返回给页面
		OutputStream outputStream= response.getOutputStream();
		// 关流
		try {
			ImageIO.write(image, imageFormat, outputStream);
		} finally {
			outputStream.close();
		}
	}

讲解一下,前端发送请求过来,具体携带的参数,因人而异。携带的是前端生成的订单号,以及支付价格。微信的支付价格一般是分, Controller 接收到请求后,拿到参数,然后下单对接微信平台,下单成功会返回一个二维码的url,然后自行生成二维码。将二维码返回给页面,用户扫码支付后,微信平台会回调你所填写的异步回调通知接口,验证签名之后,解析平台给你返回的参数。

源码后续整理后上传!

【微信支付】微信支付之 Native 支付 概述   Native支付是商户系统按微信支付协议生成支付二维码,用户再用微信“扫一扫”完成支付的模式。该模式适用于PC网站支付、实体店单品或订单支付、媒体广告支付等场景。   详情见开发文档。 前期准备   注册微信支付商户号,获取商户号 mch_id、key;   申请微信认证的服务号、政府或媒体类订阅号、小程序、APP、企业微信其中之一,并与商户号绑定。获取 appid。 开发步骤   N... 阅读详情

相关推荐

实现PC端微信扫码native支付功能

微信扫码native支付是一种方便快捷的支付方式,用户只需使用微信扫描二维码即可完成支付操作。对于开发者来说,实现微信扫码native支付可以为PC端应用添加更多支付选择,提高用户体验。这个方法用于生成包含指定文本的 QR 码,并返回一个 Data URL。可以通过将该 URL 分配给一个标签的src属性,或在其他需要图像 URL 的场景中使用。});

每天都要努力学习哦~~ 3210

微信支付-Native支付(网页二维码扫码微信支付)简单示例

使用Native支付实现网页生成支付二维码成功支付,简单案例。

maohe的博客 1万+

自建PC网站接入微信支付的实战指南:从零到收款

本文详细介绍了如何在PC网站上接入微信支付的完整流程,从注册商户号到配置证书,再到实战调用支付接口。通过Native支付方式,PC网站可以生成二维码实现流畅支付体验,显著提升转化率。文章还提供了避坑指南和上线前的检查清单,帮助开发者避免常见问题。

weixin_42530732的博客 416

1.1 微信Native支付 - 接入指引与支付安全

微信支付 - 中国领先的第三方支付平台 | 微信支付提供安全快捷的支付方式 (qq.com)我们可以看一下“产品中心”中的”支付产品“一个任意长度的字符串Z数据经过哈希运算之后会得到固定长度的字符串数据H,那我们就说H就是自己的哈希结果,又称作数据指纹或摘要MD5就是一个非常典型的摘要算法摘要算法特点1.不可逆:只有算法,没有秘钥,只能加密,不能解密AES算法属于对称加密的一种,需要一个秘钥去加密和解密RSA算法是非对称加密的典型算法,需要公钥和私钥。

weixin_51351637的博客 1958

微信支付Native模式接入全攻略:从商户号申请到回调处理(附Python代码)

本文详细解析了如何为自建PC网站接入微信支付Native模式,提供从商户号申请、API证书配置到核心代码实现的完整指南。文章重点阐述了安全签名生成、异步回调处理等关键步骤,并附有Python实战代码,帮助开发者构建安全可靠的网站收款系统。

weixin_29315091的博客 455

给自建PC网站接入微信支付流程

本文为开发者提供微信支付(直连商户模式)的简明接入指南。核心步骤包括:1)注册商户号获取MchID;2)配置APIv3证书与密钥;3)绑定AppID并开通支付权限;4)选择支付方式(推荐Native扫码);5)通过签名请求发起支付;6)处理加密回调通知。重点强调安全规范:证书管理、HTTPS强制、密钥保护和幂等设计。建议从沙箱测试开始,逐步实现完整的支付闭环。本文帮助开发者绕过官方文档的复杂性,快速实现自主集成的微信支付功能。

彩旗工作室的博客 3251

前端支付杂烩 - 微信支付(H5支付、JSAPI支付、Native支付)、支付宝支付、ApplePay流程

前端支付主要是包含微信支付(H5支付、JSAPI支付、Native支付)、支付宝支付、ApplePay的大概流程以及应用,避雷点等等

Komorebi的博客 9354

微信支付之Native扫码支付功能

作者:陈惠,叩丁狼教育高级讲师。原创文章,转载请注明出处。 上一篇微信支付文章:https://www.jianshu.com/p/9c322b1a5274 实现了微信公众号内H5页面进行支付的功能,但是这种方式的缺点就是必须在微信中打开付款页面才能实现,所以并不适合所有的场景。那么本篇文章,会以另外一种方式实现,使用扫码的方式来进行支付。 需要注意的是,扫码支付分两种形式: 线下的扫码...

wolfcode_cn的博客 9951

2020微信支付之PC网站(Native)支付详解

了解支付模式 Native 适用场景: Native支付是指商户系统按微信支付协议生成支付二维码,用户再用微信“扫一扫”完成支付的模式。该模式适用于PC网站、实体店单品或订单、媒体广告支付等场景。 解释: 这里描述一下PC端业务场景,例如:你在网站上购买东西,选择好商品后,会生成一个支付二维码,扫码支付后,商品的库存就减少了。 还有,自动贩卖机,选择商品后会生成支付二维码,扫码支付后,商品就会掉下来。 开发前准备 申请认证公众号 (若已有公众号则可跳过, 注意: 1. 公众号类型需要为服务号或者订阅号

码蝗的博客 1849

PC网站接入微信(Native)支付-扫码

创建完订单后向微信发起创建预支付订单请求,然后会返回code_url,是二维码的url,前端用qrcode库转成待支付的二维码,然后用户进行扫码支付(二维码默认俩小时内有效)以上就是接入微信Native支付的流程 申请好对应的相关信息后直接引入微信的sdk 有没有很方便!ApiV3秘钥(商户内自行设置的,并设置操作密码保存)可选择适合其接入方式,我们目前选择的是Native支付接入。5. 微信回调商户平台接口 -> 微信二维码扫码支付成功后。4. 微信接入创建支付订单。3. 微信支付业务流程。

withme977的博客 4170

PC端网站应用接入微信NATIVE支付的实战指南

本文详细解析了在PC端网站应用中接入微信NATIVE支付(即微信扫码支付)的完整实战流程。针对开发者在微信开放平台绑定网站应用AppID时遇到的常见难题,提供了清晰的解决方案与客服沟通技巧。文章涵盖从商户号绑定、API密钥配置,到后端生成支付订单、签名、处理回调通知,以及前端展示二维码与状态轮询的全链路代码实现与避坑指南,帮助开发者高效实现安全、流畅的PC端扫码支付功能。

palm99的专栏 757

【weixin】微信支付---PC网站微信支付

一、PC网站支付 微信支付支持完成域名ICP备案的网站接入支付功能。PC网站接入支付后,可以通过JSAPI支付或Native支付,自行开发生成二维码,用户使用微信“扫一扫”来完成支付。 二、支付产品介绍 JSAPI支付:商家张贴收款码物料,用户打开扫一扫,扫码后输入金额,完成付款;开发文档 Native支付:商家在系统中按微信支付协议生成支付二维码,用户扫码拉起微信收银台,...

weixin_34294649的博客 1255

SpringBoot不用三方框架,怎么动态调度定时任务,ScheduledExecutorService 详解

Spring Boot 提供了强大的定时任务支持,无需依赖任何第三方框架,即可轻松实现可配置的定时任务。通过使用 `@EnableScheduling` 注解启用定时任务支持后,我们可以利用 `@Scheduled` 注解来定义定时任务的方法,这些方法可以在指定的时间间隔或特定时间点自动执行。 我们还可以通过集成 `ScheduledExecutorService` 来实现灵活的定时任务管理。`ScheduledExecutorService` 是 Java 标准库的一部分,能够以固定速率或延迟执行任务,

横竖撇折点 1944

别再为微信支付回调头疼了!用Go+Vue搞定PC网站扫码支付(附完整代码)

本文详细介绍了如何使用Go+Vue实现微信支付Native扫码支付功能,涵盖从二维码生成到支付结果异步通知的全流程技术细节。通过实战代码示例,帮助开发者高效解决PC端网站接入微信支付的核心问题,包括回调处理、状态同步等关键环节,提升支付系统的可靠性和用户体验。

weixin_33404102的博客 352

ADC INL&DNL测试方法和实例

本文介绍了一种可操作的ADC INL和DNL的测试方法--直方图法(也称码密度法)。并实际使用该方法测试了两款芯片的ADC INL和DNL

APTCHIP的博客 1万+

流媒体协议-RTMP简介

与rtsp 不同,RTSP(Real-Time Streaming Protocol)是一个控制协议,负责控制媒体流的传输,但不传输媒体数据本身。RTSP 可以通过 TCP 或 UDP 传输 RTP 包来传输音视频数据。 RTMP(Real-Time Messaging Protocol)是一个综合性的协议,不仅可以传输音视频数据,还可以传输信令控制指令。RTMP 使用 TCP 作为传输协议,可以直接在 TCP 连接上传输音视频数据,也可以传输控制指令,实现了音视频流的实时传输和控制

xiaoshuaijinniu的博客 4563

微信支付方式总览

微信支付方式总览

嗨,欢迎来到我的 CSDN 博客小天地!一名深耕多年的技术发烧友。在这里,我将把日常工作中积累的宝贵经验,从复杂架构设计的精妙之处,到代码优化的实战技巧,毫无保留地分享给大家。 1万+

国科大人工智能原理与算法-2024-第一次作业-雷震老师

1. 反射行动(比如从热炉子上缩回你的手)是理性的吗?它们是智能的吗? 2. 以下的计算机系统在何种程度上是人工智能的实例: - 超市条码扫描器 - 网络搜索引擎 - 语音激活的电话菜单 - 对网络状态动态响应的网络路由算法 3. 为什么进化会倾向于导致行为合理的系统?设计这样的系统想达到的目标是什么?

MatsumotoChrikk 2949

微信支付(Native)

一.支付方式 1.付款码支付 付款码支付是用户展示付款码,然后商家通过扫描用户的付款码来完成支付。 2.Native支付 Native支付是商户系统按微信支付协议生成支付二维码,用户再用微信"扫一扫"完成支付的模式。该模式适用于PC网站支付、实体店单品或订单支付、媒体广告支付等场景。 订单金额商家指定,用户扫描后不能更改支付金额。 总结特点∶生成的二维码是微信的URL地址扫描二维码直接打开微信客户端完成支付 3.JSAPI支付...

w7486的博客 4824

【RT-DETR有效改进】计算训练好权重文件对应的FPS、推理每张图片的平均时间(科研必备)

本文给大家带来的改进机制是利用我们训练好的权重文件计算FPS,同时打印每张图片所利用的平均时间,模型大小(以MB为单位),同时支持batch_size功能的选择,对于轻量化模型的读者来说,本文的内容对你一定有帮助,可以清晰帮你展示出模型速度性能的提升以及轻量化的效果(模型大小),对于以提高精度为目的的读者本文也能够帮助大家展示出现阶段的模型速度指标。所以本文的内容是十分有用的机制,对于大家发表论文来说,下面的图片为运行后的效果可以看到,该有的指标均已打印(本文内容为我独家创新,全网无第二份)下面是效果图和文

Snu77的博客 3637

分布式锁特点、以及用python3实现redis分布式锁

以下是 Python3 实现 Redis 分布式锁的详细教程,包含代码示例、原理说明及最佳实践。

数据知道的博客 2万+

PC网站微信扫码支付之Native支付(模式二)

简介 Native支付是指商户系统按微信支付协议生成支付二维码,用户再用微信“扫一扫”完成支付的模式。该模式适用于PC网站、实体店单品或订单、媒体广告支付等场景。 Native支付的两种模式(本次介绍模式二) 模式一:商户后台系统根据微信支付规则链接生成二维码,链接中带固定参数productid(可定义为产品标识或订单号),用户扫码后,微信支付系统将productid和用户唯一标识(openid)回调商户后台系统(需要设置支付回调URL),商户后台系统根据productid生成支付交易,最后微信支付系

CSDN_LIJUN的博客 9425

车企自动泊车技术全解|纯视觉/多传感器融合双路线、端到端大模型革新 助力机械车位/无划线车位/极窄车位精准泊车落地

随着智能驾驶技术全面下沉,自动泊车已从高端车型专属配置,普及至十万级家用车型,成为车载核心刚需功能。但市面主流车企的泊车能力差距极大,核心差异源于传感器硬件架构、算法迭代逻辑、场景训练体系的全方位分化。传统规则式泊车算法仅适配标准划线车位,面对地库暗光、标线磨损、机械双层车位、极窄靠墙车位、无划线空地泊车等真实长尾场景极易失效。

getusushu的博客 122

网站接入微信支付详细步骤

微信开发文档:https://pay.weixin.qq.com/wiki/doc/api/index.html 1、注册微信支付商家 2、PC站申请【Native支付】、手机站申请【H5支付】;自适应网站2个都申请 3、下载微信支付demo Native支付:https://pay.weixin.qq.com/wiki/doc/api/native.php?chapter=11_1 ...

qq_22146195的博客 9464

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

Probability and Statistics - 4th edition

Probability and Statistics - 4th edition

在线支付系列【14】微信支付实战篇之Native支付下单

Native支付是指商户系统按微信支付协议生成支付二维码,用户再用微信“扫一扫”完成支付的模式。开通流程:在入驻时选择PC网站场景的商户系统默认开通此功能,其他商户如有需要,可以在入驻后前往商户平台-产品中心-Native支付-申请开通。应用场景:适用于PC网站、实体店单品或订单、媒体广告支付等场景。具体操作流程如下:商户根据微信支付的规则,为不同商品生成不同的二维码(如图3.1),展示在各种场景,用于用户扫描购买。

记录知识、锤炼自我 3717

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

上一篇: maven同依赖不同版本报错问题(缺少方法等)
下一篇: 5分钟Git从入门到使用(git笔记)
JavaBuilt
博客等级 码龄10年 1106粉丝 69原创
评论 5
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值
⌂ 换网址