mirror of
https://gitee.com/egzosn/pay-java-parent.git
synced 2026-06-02 05:50:29 +08:00
增加支付教程
This commit is contained in:
@@ -23,6 +23,32 @@
|
||||
```
|
||||
|
||||
|
||||
#### 网络请求配置
|
||||
|
||||
```java
|
||||
|
||||
HttpConfigStorage httpConfigStorage = new HttpConfigStorage();
|
||||
/* 网路代理配置 根据需求进行设置**/
|
||||
//http代理地址
|
||||
httpConfigStorage.setHttpProxyHost("192.168.1.69");
|
||||
//代理端口
|
||||
httpConfigStorage.setHttpProxyPort(3308);
|
||||
//代理用户名
|
||||
httpConfigStorage.setHttpProxyUsername("user");
|
||||
//代理密码
|
||||
httpConfigStorage.setHttpProxyPassword("password");
|
||||
/* /网路代理配置 根据需求进行设置**/
|
||||
|
||||
/* 网络请求ssl证书 根据需求进行设置**/
|
||||
//设置ssl证书路径
|
||||
httpConfigStorage.setKeystorePath("证书绝对路径");
|
||||
//设置ssl证书对应的密码
|
||||
httpConfigStorage.setStorePassword("证书对应的密码");
|
||||
/* /网络请求ssl证书**/
|
||||
|
||||
```
|
||||
|
||||
|
||||
####创建支付服务
|
||||
|
||||
|
||||
@@ -30,6 +56,9 @@
|
||||
//支付服务
|
||||
PayService service = new AliPayService(aliPayConfigStorage);
|
||||
|
||||
//设置网络请求配置根据需求进行设置
|
||||
//service.setRequestTemplateConfigStorage(httpConfigStorage)
|
||||
|
||||
```
|
||||
|
||||
####创建支付订单信息
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.egzosn.pay.ali.api;
|
||||
import com.egzosn.pay.common.api.BasePayConfigStorage;
|
||||
|
||||
/**
|
||||
* 支付客户端配置存储
|
||||
* 支付配置存储
|
||||
* author egan
|
||||
*
|
||||
* email egzosn@gmail.com
|
||||
|
||||
@@ -23,7 +23,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 支付宝支付通知
|
||||
* 支付宝支付服务
|
||||
* @author egan
|
||||
*
|
||||
* email egzosn@gmail.com
|
||||
@@ -293,7 +293,6 @@ public class AliPayService extends BasePayService {
|
||||
|
||||
/**
|
||||
* 生成二维码支付
|
||||
* 暂未实现或无此功能
|
||||
* @param order 发起支付的订单信息
|
||||
* @return 返回图片信息,支付时需要的
|
||||
*/
|
||||
|
||||
@@ -34,6 +34,7 @@
|
||||
<groupId>log4j</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- / log4j -->
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -121,6 +121,7 @@ public class ClientHttpRequest<T> extends HttpEntityEnclosingRequestBase impleme
|
||||
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public T handleResponse(HttpResponse response) throws ClientProtocolException, IOException {
|
||||
final StatusLine statusLine = response.getStatusLine();
|
||||
|
||||
@@ -48,18 +48,21 @@ public class ApyAccountRepository {
|
||||
|
||||
ApyAccount apyAccount2 = new ApyAccount();
|
||||
apyAccount2.setPayId(2);
|
||||
apyAccount2.setPartner("208******978307");
|
||||
apyAccount2.setAppid("201*******73474");
|
||||
apyAccount2.setPublicKey("MIGfMA0GCSqGSIb3DQEBAQUAA4GNADCBiQ*********VGi60j8Ue1efIlzPXV9je9Hf8sxHi/fEsraprwCtzvzQETrNRwVxLO5jVmR");
|
||||
apyAccount2.setPrivateKey("MIICdwIBADANm**********Zpmz2oK8dAxH/iqyqxb4r9IODsMgzziNBgkqhkiG9w0BAQEFAASCAcmBhTDnqQZE0jeJ9yTAemSqJefIMHBTG+MvONrWg");
|
||||
apyAccount2.setNotifyUrl("http://pay.egan.in/payBack2.json");
|
||||
// 无需同步回调可不填 app填这个就可以
|
||||
apyAccount2.setReturnUrl("m.alipay.com");
|
||||
apyAccount2.setSeller("egzosn@gmail.com");
|
||||
apyAccount2.setPartner("2088102169916436");
|
||||
apyAccount2.setAppid("2016080400165436");
|
||||
// TODO 2017/2/9 16:20 author: egan sign_type只有单一key时public_key与private_key相等,比如sign_type=MD5的情况
|
||||
apyAccount2.setPublicKey("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kKKo34bNgne6YtLibzamSe2RQNnqRykasrKEibtrUtFoyyzHRhUEjhW4la9je0H3weeyEIqYYrwq3kmQKBgQDUpKh2rmj54ovN7YAk0RkFj495od7IKN4EXRfjeiZHVrsJ97LNzYh2ldh8LRuHOGNP1jI5lBA6UL+VdjObtAiP0a3i5mLgREQ6vU4aQVEgVXiFTiFpgiwURHk3uX7S7DiOolvChmO9UTR91vaATMsTo4/uBLAkC0tQhxLrP/LAIwKBgQCmJ7tBQ9PgKeZCVcfEJQTSUwYeQD+TozjmkBCyn4S6U3pntZAj9XTUVKRiu1pvRCZZ8xjSHQ+xut8wcO4cBCUxSslDWD84HAAj5Aae80Ws7vBq6gS9G3ko1kVxLOOfA/74rB49BUEOcx9P6E2MWVSYhvtzyPvYi0PvLDQGRx2j3wKBgCRzPTVq3C/Jd7GK/qZQ+XsMismMx8WDy9rvokKqE5my8kjZHttMWhIJyZwvl0Jslgl/bAiWqtl0MgMKyfnsuHL+vFHisBxFV3TCMnspqyBhxlEDfZK6b5fhzO2SbHz3ZRJ+HkCQDNTM8LSJfqOrhjwNk4R3ZUIodXaOUN3mjlQFAoGASUJ7betaIBxZSiZITlOELLgummf5oD73d7FNq3RqMT1dWxzS0QgI2xX25RF2bli+ECr/ZqUpplOe1Nz2H6Q0QeeXlfny5epypWCFCtB4iCdSGdHVBQx3/2l6dMw2EIbShRJewsjuRlC8HZ9vkdJRWm8pr4OOh4vgCDSVO69fgkECgYEA0sjX815xMCwO1PDf+7/DNfJ5a2bYdMkVRe6y6a/Dzf83bJDdYZsOKlmSim49kPKEYU9MAT6Mst0Et9GpbzYDIZ4wj6aL01ckYvI42nhn2iylzYz+rOsg8mircFVcwiOh27BoNm8xpMFNzaY743gn37B8n3PaFboXWMO96y2rl8k=");
|
||||
apyAccount2.setNotifyUrl("http://pay.egan.in/payBack1.json");
|
||||
// 无需同步回调可不填
|
||||
apyAccount2.setReturnUrl("http://192.168.1.58:9096/payBack2.json");
|
||||
apyAccount2.setInputCharset("UTF-8");
|
||||
apyAccount2.setSeller("2088102169916436");
|
||||
apyAccount2.setSignType(SignUtils.RSA2.name());
|
||||
apyAccount2.setPayType(PayType.aliPay);
|
||||
apyAccount2.setMsgType(MsgType.text);
|
||||
//设置测试环境
|
||||
apyAccount2.setTest(true);
|
||||
apyAccounts.put(apyAccount2.getPayId(), apyAccount2);
|
||||
|
||||
ApyAccount apyAccount3 = new ApyAccount();
|
||||
|
||||
@@ -64,17 +64,17 @@ public class PayResponse {
|
||||
*/
|
||||
public HttpConfigStorage getHttpConfigStorage(ApyAccount apyAccount){
|
||||
HttpConfigStorage httpConfigStorage = new HttpConfigStorage();
|
||||
/*
|
||||
//http代理地址
|
||||
httpConfigStorage.setHttpProxyHost("192.168.1.69");
|
||||
//代理端口
|
||||
httpConfigStorage.setHttpProxyPort(3308);
|
||||
//代理用户名
|
||||
httpConfigStorage.setHttpProxyUsername("user");
|
||||
//代理密码
|
||||
httpConfigStorage.setHttpProxyPassword("password");
|
||||
/* 网路代理配置 根据需求进行设置*/
|
||||
// //http代理地址
|
||||
// httpConfigStorage.setHttpProxyHost("192.168.1.69");
|
||||
// //代理端口
|
||||
// httpConfigStorage.setHttpProxyPort(3308);
|
||||
// //代理用户名
|
||||
// httpConfigStorage.setHttpProxyUsername("user");
|
||||
// //代理密码
|
||||
// httpConfigStorage.setHttpProxyPassword("password");
|
||||
|
||||
|
||||
*/
|
||||
//设置ssl证书路径
|
||||
httpConfigStorage.setKeystorePath(apyAccount.getKeystorePath());
|
||||
//设置ssl证书对应的密码
|
||||
|
||||
24
pay-java-union/pom.xml
Normal file
24
pay-java-union/pom.xml
Normal file
@@ -0,0 +1,24 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<artifactId>pay-java-parent</artifactId>
|
||||
<groupId>com.egzosn</groupId>
|
||||
<version>2.0.4-SNAPSHOT</version>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
|
||||
<artifactId>pay-java-union</artifactId>
|
||||
|
||||
<dependencies>
|
||||
|
||||
<!-- pay-java -->
|
||||
<dependency>
|
||||
<groupId>com.egzosn</groupId>
|
||||
<artifactId>pay-java-common</artifactId>
|
||||
</dependency>
|
||||
<!-- /pay-java -->
|
||||
|
||||
</dependencies>
|
||||
</project>
|
||||
@@ -0,0 +1,85 @@
|
||||
package com.egzosn.pay.union.api;
|
||||
|
||||
import com.egzosn.pay.common.api.BasePayConfigStorage;
|
||||
|
||||
/**
|
||||
* 支付客户端配置存储
|
||||
* author egan
|
||||
*
|
||||
* email egzosn@gmail.com
|
||||
* date 2016-5-18 14:09:01
|
||||
*/
|
||||
public class UnionPayConfigStorage extends BasePayConfigStorage {
|
||||
|
||||
// 商户PID
|
||||
public volatile String merId ;
|
||||
// 商户签约拿到的pid,partner_id的简称,合作伙伴身份等同于 partner
|
||||
public volatile String pid ;
|
||||
//partner_id的简称,合作伙伴身份
|
||||
// public volatile String partner ;
|
||||
|
||||
// 商户收款账号
|
||||
public volatile String seller;
|
||||
//公钥
|
||||
private volatile String aliPublicKey;
|
||||
//全渠道固定值
|
||||
public static String version = "5.0.0";
|
||||
|
||||
public String getAliPublicKey() {
|
||||
return aliPublicKey;
|
||||
}
|
||||
|
||||
public void setAliPublicKey(String aliPublicKey) {
|
||||
setKeyPublic(aliPublicKey);
|
||||
this.aliPublicKey = aliPublicKey;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@Override
|
||||
public String getAppid() {
|
||||
return null;
|
||||
}
|
||||
|
||||
/**
|
||||
* @see #getPid()
|
||||
* @return 合作者id
|
||||
*/
|
||||
@Deprecated
|
||||
@Override
|
||||
public String getPartner() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* 设置合作者id
|
||||
* @see #setPid(String)
|
||||
* @param partner 合作者id
|
||||
*/
|
||||
@Deprecated
|
||||
public void setPartner(String partner) {
|
||||
this.pid = partner;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPid() {
|
||||
return pid;
|
||||
}
|
||||
|
||||
public void setPid(String pid) {
|
||||
this.pid = pid;
|
||||
}
|
||||
|
||||
public String getSeller() {
|
||||
return seller;
|
||||
}
|
||||
|
||||
public void setSeller(String seller) {
|
||||
this.seller = seller;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
||||
@@ -20,14 +20,41 @@
|
||||
|
||||
```
|
||||
|
||||
#### 网络请求配置
|
||||
|
||||
```java
|
||||
|
||||
HttpConfigStorage httpConfigStorage = new HttpConfigStorage();
|
||||
/* 网路代理配置 根据需求进行设置**/
|
||||
//http代理地址
|
||||
httpConfigStorage.setHttpProxyHost("192.168.1.69");
|
||||
//代理端口
|
||||
httpConfigStorage.setHttpProxyPort(3308);
|
||||
//代理用户名
|
||||
httpConfigStorage.setHttpProxyUsername("user");
|
||||
//代理密码
|
||||
httpConfigStorage.setHttpProxyPassword("password");
|
||||
/* /网路代理配置 根据需求进行设置**/
|
||||
|
||||
/* 网络请求ssl证书 根据需求进行设置**/
|
||||
//设置ssl证书路径
|
||||
httpConfigStorage.setKeystorePath("证书绝对路径");
|
||||
//设置ssl证书对应的密码
|
||||
httpConfigStorage.setStorePassword("证书对应的密码");
|
||||
/* /网络请求ssl证书**/
|
||||
|
||||
```
|
||||
|
||||
####创建支付服务
|
||||
|
||||
```java
|
||||
```java
|
||||
|
||||
//支付服务
|
||||
PayService service = new WxPayService(wxPayConfigStorage);
|
||||
|
||||
//设置网络请求配置根据需求进行设置
|
||||
//service.setRequestTemplateConfigStorage(httpConfigStorage)
|
||||
|
||||
```
|
||||
|
||||
####创建支付订单信息
|
||||
|
||||
@@ -3,7 +3,7 @@ package com.egzosn.pay.wx.api;
|
||||
import com.egzosn.pay.common.api.BasePayConfigStorage;
|
||||
|
||||
/**
|
||||
* 支付客户端配置存储
|
||||
* 微信配置存储
|
||||
* @author egan
|
||||
*
|
||||
* <pre>
|
||||
|
||||
@@ -24,7 +24,7 @@ import java.text.SimpleDateFormat;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* 支付宝支付通知
|
||||
* 微信支付服务
|
||||
* @author egan
|
||||
* <pre>
|
||||
* email egzosn@gmail.com
|
||||
@@ -320,7 +320,6 @@ public class WxPayService extends BasePayService {
|
||||
|
||||
/**
|
||||
* 获取输出二维码,用户返回给支付端,
|
||||
* 暂未实现或无此功能
|
||||
* @param order 发起支付的订单信息
|
||||
* @return 返回图片信息,支付时需要的
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user