支付对接
This commit is contained in:
@@ -30,10 +30,7 @@
|
||||
<hutool-all.version>5.7.20</hutool-all.version>
|
||||
<jodconverter.version>2.2.2</jodconverter.version>
|
||||
<openoffice.version>4.1.2</openoffice.version>
|
||||
<emoji-java.veision>4.0.0</emoji-java.veision>
|
||||
<pinyin4j.veision>2.5.1</pinyin4j.veision>
|
||||
<commons-io.version>2.4</commons-io.version>
|
||||
<jsoup.veision>1.12.1</jsoup.veision>
|
||||
<poitl.version>1.9.1</poitl.version>
|
||||
<easypoi.version>4.2.0</easypoi.version>
|
||||
<jetty.version>9.4.56.v20240826</jetty.version>
|
||||
@@ -143,14 +140,6 @@
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>websocket-server</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>websocket-server</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>javax-websocket-server-impl</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>javax-websocket-server-impl</artifactId>
|
||||
@@ -252,7 +241,7 @@
|
||||
<groupId>org.nutz</groupId>
|
||||
<artifactId>nutz-integration-json4excel</artifactId>
|
||||
<version>${nutz.version}</version>
|
||||
<exclusions><!-- 手动排除依赖,瘦身 -->
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
@@ -277,13 +266,11 @@
|
||||
<artifactId>aspose-words</artifactId>
|
||||
<version>23.1</version>
|
||||
</dependency>
|
||||
<!--xlsx或xls转pdf-->
|
||||
<dependency>
|
||||
<groupId>com.luhuiguo</groupId>
|
||||
<artifactId>aspose-cells</artifactId>
|
||||
<version>23.1</version>
|
||||
</dependency>
|
||||
<!--ppt转pdf-->
|
||||
<dependency>
|
||||
<groupId>com.luhuiguo</groupId>
|
||||
<artifactId>aspose-slides</artifactId>
|
||||
@@ -338,19 +325,16 @@
|
||||
<artifactId>thumbnailator</artifactId>
|
||||
<version>0.4.8</version>
|
||||
</dependency>
|
||||
<!--hutool-->
|
||||
<dependency>
|
||||
<groupId>cn.hutool</groupId>
|
||||
<artifactId>hutool-all</artifactId>
|
||||
<version>${hutool-all.version}</version>
|
||||
</dependency>
|
||||
<!--lombok-->
|
||||
<dependency>
|
||||
<groupId>org.projectlombok</groupId>
|
||||
<artifactId>lombok</artifactId>
|
||||
<version>${lombok.version}</version>
|
||||
</dependency>
|
||||
<!-- 转pdf用 -->
|
||||
<dependency>
|
||||
<groupId>com.artofsolving</groupId>
|
||||
<artifactId>jodconverter</artifactId>
|
||||
@@ -393,7 +377,6 @@
|
||||
<artifactId>ridl</artifactId>
|
||||
<version>${openoffice.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.openoffice</groupId>
|
||||
<artifactId>unoil</artifactId>
|
||||
@@ -409,13 +392,13 @@
|
||||
<dependency>
|
||||
<groupId>com.vdurmont</groupId>
|
||||
<artifactId>emoji-java</artifactId>
|
||||
<version>${emoji-java.veision}</version>
|
||||
<version>${emoji-java.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.belerweb</groupId>
|
||||
<artifactId>pinyin4j</artifactId>
|
||||
<version>${pinyin4j.veision}</version>
|
||||
<version>${pinyin4j.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
@@ -427,6 +410,8 @@
|
||||
<artifactId>commons-io</artifactId>
|
||||
<version>${commons-io.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 只保留1次,已删除重复 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
@@ -442,21 +427,19 @@
|
||||
<artifactId>poi-ooxml-schemas</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>ooxml-schemas</artifactId>
|
||||
<version>1.4</version>
|
||||
</dependency>
|
||||
|
||||
<!-- 只保留1次,已删除重复 -->
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- 导出导入 文档/excel 用 -->
|
||||
<dependency>
|
||||
<groupId>cn.afterturn</groupId>
|
||||
<artifactId>easypoi-base</artifactId>
|
||||
@@ -493,7 +476,7 @@
|
||||
<groupId>com.deepoove</groupId>
|
||||
<artifactId>poi-tl</artifactId>
|
||||
<version>${poitl.version}</version>
|
||||
<exclusions><!-- 手动排除依赖,瘦身 -->
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
@@ -530,19 +513,16 @@
|
||||
<artifactId>asm-util</artifactId>
|
||||
<version>7.3.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>asm</groupId>
|
||||
<artifactId>asm-all</artifactId>
|
||||
<version>2.1</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.openjdk.nashorn</groupId>
|
||||
<artifactId>nashorn-core</artifactId>
|
||||
<version>15.3</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.aliyun</groupId>
|
||||
<artifactId>darabonba-java-core</artifactId>
|
||||
@@ -563,23 +543,12 @@
|
||||
<artifactId>mail</artifactId>
|
||||
<version>1.4.7</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.poi</groupId>
|
||||
<artifactId>poi-ooxml</artifactId>
|
||||
<version>${poi.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>javax.annotation</groupId>
|
||||
<artifactId>javax.annotation-api</artifactId>
|
||||
<version>1.3.2</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ws.schild</groupId>
|
||||
<artifactId>jave-all-deps</artifactId>
|
||||
@@ -626,7 +595,6 @@
|
||||
<artifactId>java-jwt</artifactId>
|
||||
<version>3.1.0</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.google.zxing</groupId>
|
||||
<artifactId>javase</artifactId>
|
||||
@@ -678,7 +646,6 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>com.tencentcloudapi</groupId>
|
||||
<artifactId>tencentcloud-sdk-java</artifactId>
|
||||
@@ -695,8 +662,6 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
|
||||
<!-- api token web server -->
|
||||
<dependency>
|
||||
<groupId>io.jsonwebtoken</groupId>
|
||||
<artifactId>jjwt</artifactId>
|
||||
@@ -708,24 +673,18 @@
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<!-- html -->
|
||||
<dependency>
|
||||
<groupId>org.jsoup</groupId>
|
||||
<artifactId>jsoup</artifactId>
|
||||
<version>${jsoup.veision}</version>
|
||||
<version>${jsoup.version}</version>
|
||||
</dependency>
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-api</artifactId>
|
||||
<version>${slf4j.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>ch.qos.logback</groupId>
|
||||
<artifactId>logback-core</artifactId>
|
||||
@@ -741,7 +700,6 @@
|
||||
<artifactId>easy-captcha</artifactId>
|
||||
<version>${easy-captcha.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>commons-validator</groupId>
|
||||
<artifactId>commons-validator</artifactId>
|
||||
@@ -763,6 +721,16 @@
|
||||
<artifactId>websocket-server</artifactId>
|
||||
<version>${jetty.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
<version>1.69</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.bouncycastle</groupId>
|
||||
<artifactId>bcpkix-jdk15on</artifactId>
|
||||
<version>1.69</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.jetty.websocket</groupId>
|
||||
<artifactId>javax-websocket-server-impl</artifactId>
|
||||
@@ -775,6 +743,7 @@
|
||||
</exclusions>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
@@ -789,10 +758,13 @@
|
||||
<artifactId>jaxb-api</artifactId>
|
||||
<version>${jaxb-api.version}</version>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<!-- 只保留1个编译插件,已删除重复 -->
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
@@ -803,6 +775,7 @@
|
||||
<useIncrementalCompilation>false</useIncrementalCompilation>
|
||||
</configuration>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-javadoc-plugin</artifactId>
|
||||
@@ -812,14 +785,6 @@
|
||||
<charset>UTF-8</charset>
|
||||
<docencoding>UTF-8</docencoding>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>attach-javadocs</id>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@@ -828,14 +793,6 @@
|
||||
<configuration>
|
||||
<attach>true</attach>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<phase>compile</phase>
|
||||
<goals>
|
||||
<goal>jar</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
@@ -851,16 +808,9 @@
|
||||
<artifactId>nutzboot-maven-plugin</artifactId>
|
||||
<version>${nutzboot.version}</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>15</source>
|
||||
<target>15</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<repositories>
|
||||
<repository>
|
||||
<id>nutz</id>
|
||||
@@ -891,4 +841,4 @@
|
||||
</releases>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
</project>
|
||||
</project>
|
||||
@@ -3,6 +3,7 @@ package io.v.nutz.pay.bank.china;
|
||||
|
||||
import cn.hutool.core.date.DateUtil;
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import io.v.nutz.pay.bank.china.pojo.WxAppPayRequestParams;
|
||||
import io.v.nutz.pay.bank.china.pojo.WxAppPayResponse;
|
||||
@@ -27,7 +28,6 @@ import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.w3c.dom.Document;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
@@ -138,7 +138,7 @@ public class BankChinaWxPayService {
|
||||
// 交易终端类型
|
||||
payParams.setTerminalChnl(chnlEnum.getCode());
|
||||
// 交易类型
|
||||
payParams.setTradeType(WxPayTradeTypeEnum.APP_WX.getCode());
|
||||
payParams.setTradeType(WxPayTradeTypeEnum.WXAPP.getCode());
|
||||
// 子商户公众账号ID
|
||||
payParams.setSubAppid(payProperties.getSubAppid());
|
||||
// 设备号
|
||||
@@ -163,7 +163,7 @@ public class BankChinaWxPayService {
|
||||
String signData = BankPaySign.getInstance().getSinData(payProperties.getSignKeyFile(), payProperties.getSignkeyPassword(), payProperties.getSignkeyPassword(), businessSignData);
|
||||
log.info("中国银行微信APP订单支付签名:signData={}", signData);
|
||||
payParams.setSignData(signData);
|
||||
log.info("中国银行微信APP订单支付参数:{}", payParams.toString());
|
||||
log.info("中国银行微信APP订单支付参数:{}", JSONUtil.toJsonPrettyStr(payParams));
|
||||
|
||||
List<NameValuePair> formParams = payParams.formParams();
|
||||
log.info("中国银行微信APP订单支付发送参数:{}", JSONObject.toJSONString(formParams));
|
||||
|
||||
@@ -0,0 +1,51 @@
|
||||
package io.v.nutz.pay.bank.china.controller;
|
||||
|
||||
import io.v.nutz.pay.annotations.Api;
|
||||
import io.v.nutz.pay.annotations.ApiOperation;
|
||||
import io.v.nutz.pay.cache.ChinaBankOrderWaitPayCacheService;
|
||||
import io.v.nutz.pay.record.service.IMemberPayRecordService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.integration.jedis.RedisService;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
import org.nutz.mvc.annotation.At;
|
||||
import org.nutz.mvc.annotation.Ok;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
|
||||
/**
|
||||
* 支付通知 controller
|
||||
*/
|
||||
@IocBean
|
||||
@Api("支付通知")
|
||||
@At("/notify")
|
||||
@Slf4j
|
||||
public class BankNotifyController
|
||||
{
|
||||
|
||||
@Inject
|
||||
private IMemberPayRecordService memberPayRecordService;
|
||||
|
||||
@Inject
|
||||
private RedisService redisService;
|
||||
|
||||
private final static String SSK_MEMBER_PAY_ORDER_RECORD = "SSK:MEMBER:PAY:ORDER:RECORD:";
|
||||
|
||||
@Inject
|
||||
private ChinaBankOrderWaitPayCacheService chinaBankOrderWaitPayCacheService;
|
||||
|
||||
|
||||
@Ok("json")
|
||||
@At("/china/bank/pay")
|
||||
@ApiOperation("通过支付商品交易单号查询支付记录")
|
||||
public void cashRecvDcepNotify(HttpServletRequest request) {
|
||||
|
||||
log.info("---------- Begin ReceiveNB2BRecvOrderNotice ----------");
|
||||
String message = request.getParameter("message");
|
||||
String signature = request.getParameter("signature");
|
||||
log.info("[message]=[" + message + "]");
|
||||
log.info("[signature]=[" + signature + "]");
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -59,7 +59,7 @@ public class WxAppPayRequestParams extends CommonRequestParams implements Serial
|
||||
sb.append(this.getOrderTime()).append("|");
|
||||
sb.append(this.getCurCode()).append("|");
|
||||
sb.append(this.getOrderAmount()).append("|");
|
||||
sb.append(this.getMerchantNo()).append("|");
|
||||
sb.append(this.getMerchantNo());
|
||||
// sb.append(this.getOrderNote()).append("|");
|
||||
// sb.append(this.getOrderUrl()).append("|");
|
||||
// if(this.getOrderTimeoutDate() != null) {
|
||||
@@ -92,7 +92,7 @@ public class WxAppPayRequestParams extends CommonRequestParams implements Serial
|
||||
public List<NameValuePair> formParams() {
|
||||
List<NameValuePair> params = Collections.synchronizedList(new ArrayList<NameValuePair>());
|
||||
params.add(new BasicNameValuePair("merchantNo", this.getMerchantNo()));
|
||||
params.add(new BasicNameValuePair("payType", this.getPayType()));
|
||||
params.add(new BasicNameValuePair("payType", "1"));
|
||||
params.add(new BasicNameValuePair("orderNo", this.getOrderNo()));
|
||||
params.add(new BasicNameValuePair("curCode", this.getCurCode()));
|
||||
params.add(new BasicNameValuePair("orderAmount", this.getOrderAmount()));
|
||||
|
||||
@@ -4,10 +4,6 @@ import cn.hutool.core.util.StrUtil;
|
||||
import io.v.nutz.pay.util.PKCS7Tool;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.security.GeneralSecurityException;
|
||||
import java.util.Base64;
|
||||
|
||||
/**
|
||||
* 中国银行支付签名
|
||||
*/
|
||||
|
||||
@@ -2,7 +2,7 @@ package io.v.nutz.pay.enums;
|
||||
|
||||
public enum WxPayTradeTypeEnum {
|
||||
|
||||
APP_WX("APP_WX", "APP支付(微信)");
|
||||
WXAPP("WXAPP", "APP支付(微信)");
|
||||
|
||||
private String code;
|
||||
public String getCode() {
|
||||
|
||||
@@ -21,17 +21,13 @@ import io.v.nutz.pay.record.module.MemberPayRecord;
|
||||
import io.v.nutz.pay.record.service.IMemberPayRecordService;
|
||||
import io.v.nutz.pay.util.BillNoUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nutz.dao.Chain;
|
||||
import org.nutz.dao.Cnd;
|
||||
import org.nutz.dao.Dao;
|
||||
import org.nutz.dao.Sqls;
|
||||
import org.nutz.dao.sql.Sql;
|
||||
import org.nutz.ioc.loader.annotation.Inject;
|
||||
import org.nutz.ioc.loader.annotation.IocBean;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@Slf4j
|
||||
@IocBean(args = {"refer:dao"})
|
||||
@@ -137,6 +133,7 @@ public class MemberPayRecordServiceImpl extends BaseServiceImpl<MemberPayRecord>
|
||||
record.setBusinessOrderCode(paymentOrder.getOrderCode());
|
||||
record.setPayMoney(paymentOrder.getMoney());
|
||||
record.setMemberId(paymentOrder.getMemberId());
|
||||
record.setPayRemark("工会会员缴费-订单:" + paymentOrder.getOrderCode());
|
||||
|
||||
} else {
|
||||
throw new RuntimeException("不支持的支付业务");
|
||||
|
||||
@@ -1,34 +1,38 @@
|
||||
package io.v.nutz.pay.util;
|
||||
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.bouncycastle.cert.jcajce.JcaCertStore;
|
||||
import org.bouncycastle.cms.CMSProcessableByteArray;
|
||||
import org.bouncycastle.cms.CMSSignedData;
|
||||
import org.bouncycastle.cms.CMSSignedDataGenerator;
|
||||
import org.bouncycastle.cms.CMSTypedData;
|
||||
import org.bouncycastle.cms.jcajce.JcaSignerInfoGeneratorBuilder;
|
||||
import org.bouncycastle.jce.provider.BouncyCastleProvider;
|
||||
import org.bouncycastle.operator.ContentSigner;
|
||||
import org.bouncycastle.operator.jcajce.JcaContentSignerBuilder;
|
||||
import org.bouncycastle.operator.jcajce.JcaDigestCalculatorProviderBuilder;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.security.*;
|
||||
import java.security.cert.Certificate;
|
||||
import java.security.cert.X509Certificate;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.Enumeration;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class PKCS7Tool {
|
||||
public class PKCS7Tool
|
||||
{
|
||||
|
||||
// 加密算法
|
||||
private static String KEY_ALGORITHM = "SHA256withRSA";
|
||||
|
||||
public static PKCS7Tool instance() {
|
||||
return new PKCS7Tool();
|
||||
}
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Pkcs7Detach 签名
|
||||
* @param signFilePath 签名证书
|
||||
* @param password 证书秘钥
|
||||
* @param content 内容
|
||||
* @return
|
||||
*/
|
||||
public String signature(String signFilePath, String password, byte[] content){
|
||||
if (StringUtils.isEmpty(signFilePath)) {
|
||||
throw new RuntimeException("缺少证书");
|
||||
@@ -38,11 +42,9 @@ public class PKCS7Tool {
|
||||
}
|
||||
log.info("生成签名信息:signFilePath-->{}, password-->{}", signFilePath, password);
|
||||
try {
|
||||
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
|
||||
Security.addProvider(new BouncyCastleProvider());
|
||||
|
||||
//创建密钥对
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
|
||||
File file = new File(signFilePath);
|
||||
if(!file.exists()) {
|
||||
throw new RuntimeException("证书路径不存在");
|
||||
@@ -51,23 +53,32 @@ public class PKCS7Tool {
|
||||
keyStore.load(fis, password.toCharArray());
|
||||
fis.close();
|
||||
|
||||
//获取别名
|
||||
Enumeration enumas = keyStore.aliases();
|
||||
String alias = null;
|
||||
while (enumas.hasMoreElements()) {
|
||||
alias = (String) enumas.nextElement();
|
||||
}
|
||||
|
||||
//准备密钥对
|
||||
Key key = keyStore.getKey(alias, password.toCharArray());
|
||||
Signature sig = Signature.getInstance(KEY_ALGORITHM);
|
||||
// 使用私钥初始化 Signature 对象
|
||||
sig.initSign((PrivateKey) key);
|
||||
sig.update(content);
|
||||
// 生成签名
|
||||
byte[] sign = sig.sign();
|
||||
log.info("Pkcs7Detach 签名成功,加密后的密文为:{}", Base64.getEncoder().encodeToString(sign));
|
||||
return Base64.getEncoder().encodeToString(sign);
|
||||
PrivateKey privateKey = (PrivateKey) keyStore.getKey(alias, password.toCharArray());
|
||||
Certificate cert = keyStore.getCertificate(alias);
|
||||
List<Certificate> certList = new ArrayList<>();
|
||||
certList.add(cert);
|
||||
|
||||
CMSSignedDataGenerator signer = new CMSSignedDataGenerator();
|
||||
ContentSigner contentSigner = new JcaContentSignerBuilder(KEY_ALGORITHM).setProvider("BC").build(privateKey);
|
||||
signer.addSignerInfoGenerator(
|
||||
new JcaSignerInfoGeneratorBuilder(
|
||||
new JcaDigestCalculatorProviderBuilder().setProvider("BC").build()
|
||||
).build(contentSigner, (X509Certificate) cert)
|
||||
);
|
||||
signer.addCertificates(new JcaCertStore(certList));
|
||||
|
||||
CMSTypedData msg = new CMSProcessableByteArray(content);
|
||||
CMSSignedData signedData = signer.generate(msg, false);
|
||||
|
||||
String signData = Base64.getEncoder().encodeToString(signedData.getEncoded());
|
||||
log.info("Pkcs7Detach 签名成功,加密后的密文为:{}", signData);
|
||||
return signData;
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
log.error("Pkcs7Detach 签名异常:"+e.getMessage());
|
||||
@@ -92,7 +103,7 @@ public class PKCS7Tool {
|
||||
}
|
||||
log.info("验证签名信息:verifySignFilePath-->{}, password-->{}", verifySignFilePath, password);
|
||||
try {
|
||||
Security.addProvider(new org.bouncycastle.jce.provider.BouncyCastleProvider());
|
||||
Security.addProvider(new BouncyCastleProvider());
|
||||
|
||||
//创建密钥对
|
||||
KeyStore keyStore = KeyStore.getInstance("PKCS12");
|
||||
|
||||
@@ -178,7 +178,7 @@ layout("/mobile/platform.html"){
|
||||
</template>
|
||||
</van-cell>
|
||||
</van-radio-group>
|
||||
<van-submit-bar :loading="loading" :price="formData.paymentMoney" @submit="doPay" button-color="#1867b0" button-text="支付"></van-submit-bar>
|
||||
<van-submit-bar :loading="loading" :price="formData.paymentMoney" @submit="surePayOrder" button-color="#1867b0" button-text="支付"></van-submit-bar>
|
||||
</div>
|
||||
|
||||
</van-action-sheet>
|
||||
@@ -225,6 +225,13 @@ layout("/mobile/platform.html"){
|
||||
moneyModel: 2,
|
||||
intervalTimer: null,
|
||||
hasPayed: false,
|
||||
paymentMethods: [{
|
||||
title: '微信',
|
||||
type: 'wx',
|
||||
payChannel: 1,
|
||||
channelType: 1,
|
||||
icon: '/assets/mobile/svg/pay/weixin.svg',
|
||||
}],
|
||||
}
|
||||
},
|
||||
methods: {
|
||||
@@ -362,6 +369,142 @@ layout("/mobile/platform.html"){
|
||||
}
|
||||
}
|
||||
},
|
||||
// 确认支付订单
|
||||
async surePayOrder() {
|
||||
let loading = null
|
||||
vant.Dialog.confirm({
|
||||
title: '提示',
|
||||
message: '您确认要支付当前订单吗?',
|
||||
}).then(async () => {
|
||||
loading = this.$toast({
|
||||
duration: 0,
|
||||
message: '正在拉起支付,请稍候',
|
||||
forbidClick: true,
|
||||
loadingType: 'spinner',
|
||||
type: 'loading',
|
||||
overlay: true
|
||||
});
|
||||
|
||||
const payload = {}
|
||||
payload.channelType = 1
|
||||
payload.businessType = 1
|
||||
payload.payChannel = 1
|
||||
payload.businessId = this.payInfo.id
|
||||
payload.remark = '测试'
|
||||
payload.money = 0.01
|
||||
console.log('创建支付订单参数->', payload)
|
||||
// 创建支付订单 获取支付信息 拉起支付页面
|
||||
const { code, data, msg } = await $.post('/member/pay/record/pay', payload)
|
||||
if(code !== 0) {
|
||||
loading.close()
|
||||
vant.Toast.fail(msg)
|
||||
} else {
|
||||
loading.close()
|
||||
if(!data.requestResult) {
|
||||
vant.Toast.fail("订单支付拉起失败")
|
||||
return;
|
||||
}
|
||||
|
||||
// 微信支付 初始化微信JS-SDK配置
|
||||
if(paymentMethod.type === 'wx') {
|
||||
await this.loadWxJsConfig();
|
||||
|
||||
wx.ready(function () {
|
||||
|
||||
// 中国银行 微信APP支付
|
||||
if(data.payChannel === 1 && data.channelType === 1) {
|
||||
const payParams = JSON.parse(data.requestResult)
|
||||
console.log("服务端获取的支付参数payParams->", payParams)
|
||||
const prepayData = {
|
||||
appId: payParams.wcPayDataAppId, // 自己的APPID
|
||||
timeStamp: payParams.wcPayDataTimeStamp, // 时间戳
|
||||
nonceStr: payParams.wcPayDataNonceStr, // 随机字符串
|
||||
package: payParams.wcPayDataPrepayId, // 预支付订单号
|
||||
signType: payParams.wcPayDataSignType, // 签名类型
|
||||
paySign: payParams.wcPayDataPaySign // 签名
|
||||
};
|
||||
console.log("调用微信API支付参数->", prepayData)
|
||||
// 调用微信支付API
|
||||
wx.chooseWXPay({
|
||||
timestamp: prepayData.timeStamp,
|
||||
nonceStr: prepayData.nonceStr,
|
||||
package: prepayData.package,
|
||||
signType: prepayData.signType,
|
||||
paySign: prepayData.paySign,
|
||||
success: function(res) {
|
||||
// 支付成功后的操作
|
||||
console.log('支付成功');
|
||||
setTimeout(()=> {
|
||||
this.paySuccess(res, data.goodsTradeCode)
|
||||
}, 500);
|
||||
},
|
||||
cancel: function(res) {
|
||||
// 用户取消支付的操作
|
||||
console.log('支付取消');
|
||||
},
|
||||
fail: function(res) {
|
||||
// 支付失败的操作
|
||||
console.log('支付失败');
|
||||
this.payFail(res, data.goodsTradeCode)
|
||||
}
|
||||
});
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}).catch((e) => {
|
||||
if(loading) {
|
||||
loading.close()
|
||||
}
|
||||
console.log("用户支付失败->", e)
|
||||
vant.Toast("用户支付失败")
|
||||
});
|
||||
},
|
||||
|
||||
// 支付成功
|
||||
async paySuccess(res, goodsTradeCode) {
|
||||
await $.post('/member/pay/record/check/pay/code?payCode=' + goodsTradeCode)
|
||||
|
||||
const loading = this.$toast({
|
||||
duration: 0,
|
||||
message: '订单支付查询中...',
|
||||
forbidClick: true,
|
||||
loadingType: 'spinner',
|
||||
type: 'loading',
|
||||
overlay: true
|
||||
});
|
||||
|
||||
// 循环拉取支付订单信息
|
||||
await this.repeatQueryPay(loading, goodsTradeCode)
|
||||
},
|
||||
|
||||
// 循环拉取支付订单信息
|
||||
async repeatQueryPay(loading, goodsTradeCode) {
|
||||
setTimeout(async () => {
|
||||
const res = await $.post('/member/pay/record/get/by/code?goodsTradeCode=' + goodsTradeCode)
|
||||
if(res.code !== 0) {
|
||||
loading.close()
|
||||
vant.Toast.fail(msg)
|
||||
} else {
|
||||
const payRecord = res.data
|
||||
|
||||
// 支付成功
|
||||
if(payRecord.status === 1) {
|
||||
loading.close()
|
||||
// 支付失败
|
||||
} else if(payRecord.status === 2) {
|
||||
loading.close()
|
||||
} else {
|
||||
await this.repeatQueryPay(loading, goodsTradeCode)
|
||||
}
|
||||
}
|
||||
}, 1000);
|
||||
},
|
||||
|
||||
// 支付失败
|
||||
async payFail(res, goodsTradeCode) {
|
||||
await $.post('/member/pay/record/del/check/pay/code?payCode=' + goodsTradeCode)
|
||||
},
|
||||
},
|
||||
async created() {
|
||||
let nowYear = new Date().getFullYear()
|
||||
|
||||
Reference in New Issue
Block a user