
[url=https://github.com/comeforu2012/truth/wiki/chrome-lantern%ef%bc%88%e8%93%9d%e7%81%af%ef%bc%89]https://github.com/comeforu2012/truth/wiki/chrome-lantern%ef%bc%88%e8%93%9d%e7%81%af%ef%bc%89[/url]。阿里巴巴alibabahttps://github.com/alibaba/https://github.com/thx。note: so far, https://github.com/the-darkvoid/os-x-fake-pci-id, and https://github.com/rehabman/os-x-fake-pci-id are being kept in sync.。
下载地址:https://docs.open.alipay.com/270/106291/
image
image
readme.txt请好好看一下。
只有一个Java配置类,其余都是JSP。
(1).注册蚂蚁金服开发者账号(免费,不像苹果会收取费用)
注册地址:https://open.alipay.com ,用你的支付宝账号扫码登录,完善个人信息,选择服务类型(我选的是自研)。
image
(2).设置app_id和gatewayUrl
image
image
其中密钥需要自己生成微信公众号对接支付宝,appID和支付宝网关是已经给好的,网关有dev字样,表明是用于开发测试。
(3).设置密钥
image
点击“生成方法”,打开界面如下:

image
下周密钥生成工具,解压打开后,选择2048位生成密钥:
image
如果没有设置过,此时显示文本是“设置应用公钥”,我这里是已经设置过得。
image
设置方法,“打开密钥文件路径”:
image
image
复制应用公钥2048.txt中的内容到点击“设置应用公钥”的弹出框中,保存:
image
image
点击如上图链接,复制弹出框里面的内容到alipay_public_key。
如果这个设置不对,结果是:支付成功,但是验签失败。
如果是正式环境,需要上传到对应的应用中:
image
(4).服务器异步通知页面路径(notify_url)

如果没有改名,修改IP和端口号就可以了,我自己的如下:
http://localhost:8080/alipay.trade.page.pay-JAVA-UTF-8/notify_url.jsp
(5).页面跳转同步通知页面路径(return_url)
http://localhost:8080/alipay.trade.page.pay-JAVA-UTF-8/return_url.jsp
image
image
测试用的支付宝买家账户可以在“沙箱账号”这个页面可以找到:
image
支付成功后,验签结果:
image
由于我们使用的是沙箱测试环境,测试环境和正式上线的环境的网关是不一样的,如果配置错误,会出现,appid错误的问题。配置如下:
这里写图片描述
链接: https://pan.baidu.com/s/1n6GbEJiMzoGWJrSw0bb2Cg 密码: zd9e
这里写图片描述
整合到ssm一样,我们需要像沙箱测试环境一样,需要修改支付的配置信息
这里写图片描述
主要包括以下的表:
drop table if exists user;
/*==============================================================*/
/* Table: user */
/*==============================================================*/
create table user
(
id varchar(20) not null,
username varchar(128),
sex varchar(20),
primary key (id)
);
alter table user comment '用户表';
CREATE TABLE `flow` (
`id` varchar(20) NOT NULL,
`flow_num` varchar(20) DEFAULT NULL COMMENT '流水号',
`order_num` varchar(20) DEFAULT NULL COMMENT '订单号',
`product_id` varchar(20) DEFAULT NULL COMMENT '产品主键ID',
`paid_amount` varchar(11) DEFAULT NULL COMMENT '支付金额',
`paid_method` int(11) DEFAULT NULL COMMENT '支付方式\r\n 1:支付宝\r\n 2:微信',
`buy_counts` int(11) DEFAULT NULL COMMENT '购买个数',
`create_time` datetime DEFAULT NULL COMMENT '创建时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='流水表';
CREATE TABLE `orders` (
`id` varchar(20) NOT NULL,
`order_num` varchar(20) DEFAULT NULL COMMENT '订单号',
`order_status` varchar(20) DEFAULT NULL COMMENT '订单状态\r\n 10:待付款\r\n 20:已付款',
`order_amount` varchar(11) DEFAULT NULL COMMENT '订单金额',
`paid_amount` varchar(11) DEFAULT NULL COMMENT '实际支付金额',
`product_id` varchar(20) DEFAULT NULL COMMENT '产品表外键ID',
`buy_counts` int(11) DEFAULT NULL COMMENT '产品购买的个数',
`create_time` datetime DEFAULT NULL COMMENT '订单创建时间',
`paid_time` datetime DEFAULT NULL COMMENT '支付时间',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='订单表';
CREATE TABLE `product` (
`id` varchar(20) NOT NULL,
`name` varchar(20) DEFAULT NULL COMMENT '产品名称',
`price` varchar(11) DEFAULT NULL COMMENT '价格',
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='产品表 ';
这里就不介绍了,这个只包括简单的curd,可以使用通用mapper,或者逆向工程就行。
以订单order为例给出:
public interface OrdersMapper {
int countByExample(OrdersExample example);
int deleteByExample(OrdersExample example);
int deleteByPrimaryKey(String id);
int insert(Orders record);
int insertSelective(Orders record);
List<Orders> selectByExample(OrdersExample example);
Orders selectByPrimaryKey(String id);
int updateByExampleSelective(@Param("record") Orders record, @Param("example") OrdersExample example);
int updateByExample(@Param("record") Orders record, @Param("example") OrdersExample example);
int updateByPrimaryKeySelective(Orders record);
int updateByPrimaryKey(Orders record);
}
注意:源代码最后给出。
同上,最后在项目源代码里可见。
以订单order为例给出:
/**
* 订单操作 service
* @author ibm
*
*/
public interface OrdersService {
/**
* 新增订单
* @param order
*/
public void saveOrder(Orders order);
/**
*
* @Title: OrdersService.java
* @Package com.sihai.service
* @Description: 修改叮当状态,改为 支付成功,已付款; 同时新增支付流水
* Copyright: Copyright (c) 2017
* Company:FURUIBOKE.SCIENCE.AND.TECHNOLOGY
*
* @author sihai
* @date 2017年8月23日 下午9:04:35
* @version V1.0
*/
public void updateOrderStatus(String orderId, String alpayFlowNum, String paidAmount);
/**
* 获取订单
* @param orderId
* @return
*/
public Orders getOrderById(String orderId);
}
支付流程图
这里写图片描述
首先,启动项目后,输入:8080/,会进入到商品页面,如下:
这里写图片描述
下面是页面代码
商品页面(products.jsp)

这里写图片描述
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<script src="<%=request.getContextPath() %>/static/js/jquery.min.js" type="text/javascript"></script>
<html>
<head>
</head>
<body>
<table>
<tr>
<td>
产品编号
</td>
<td>
产品名称
</td>
<td>
产品价格
</td>
<td>
操作
</td>
</tr>
<c:forEach items="${pList }" var="p">
<tr>
<td>
${p.id }
</td>
<td>
${p.name }
</td>
<td>
${p.price }
</td>
<td>
<a href="<%=request.getContextPath() %>/alipay/goConfirm.action?productId=${p.id }">购买</a>
</td>
</tr>
</c:forEach>
</table>
<input type="hidden" id="hdnContextPath" name="hdnContextPath" value="<%=request.getContextPath() %>"/>
</body>
</html>
<script type="text/javascript">
$(document).ready(function() {
var hdnContextPath = $("#hdnContextPath").val();
});
</script>
本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/tongxinshuyu/article-109808-1.html
为网络时代的新生代经济助力
完蛋了
内抓汉奸