Skip to content

Commit

Permalink
Merge branches 'dev' and 'master' of https://github.com/egzosn/pay-ja…
Browse files Browse the repository at this point in the history
  • Loading branch information
egzosn committed Dec 1, 2020
2 parents 35bb30e + 9a6d262 commit 7cc3488
Show file tree
Hide file tree
Showing 81 changed files with 6,167 additions and 413 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<dependency>
<groupId>com.egzosn</groupId>
<artifactId>{module-name}</artifactId>
<version>2.13.2</version>
<version>2.13.3</version>
</dependency>

```
Expand Down Expand Up @@ -63,8 +63,12 @@ android 例子 [pay-java-android](https://gitee.com/egzosn/pay-java-android)

非常欢迎和感谢对本项目发起Pull Request的同学,不过本项目基于git flow开发流程,因此在发起Pull Request的时候请选择develop分支。

作者公众号(每周输出)
![公众号](https://egzosn.gitee.io/pay-java-parent/gzh.png "gzh.png")

E-Mail:[email protected]

QQ群:542193977

微信群: ![微信群](https://www.egzosn.com/images/wx.jpg "wx.jpg")
微信群:
![微信群](https://egzosn.gitee.io/pay-java-parent/wx.jpg "wx.jpg")
34 changes: 29 additions & 5 deletions pay-java-ali/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,10 @@
## 支付宝支付简单例子

#### 支付配置

##### 普通公钥
```java


AliPayConfigStorage aliPayConfigStorage = new AliPayConfigStorage();
aliPayConfigStorage.setPid("合作者id");
aliPayConfigStorage.setAppid("应用id");
Expand All @@ -21,6 +21,30 @@
aliPayConfigStorage.setTest(true);

```
##### 证书公钥
```java


AliPayConfigStorage aliPayConfigStorage = new AliPayConfigStorage();
aliPayConfigStorage.setPid("合作者id");
aliPayConfigStorage.setAppid("应用id");
aliPayConfigStorage.setKeyPrivate("应用私钥");
//设置为证书方式
aliPayConfigStorage.setCertSign(true);
//设置证书存储方式,这里为路径
aliPayConfigStorage.setCertStoreType(CertStoreType.PATH);
aliPayConfigStorage.setMerchantCert("请填写您的应用公钥证书文件路径,例如:d:/appCertPublicKey_2019051064521003.crt");
aliPayConfigStorage.setAliPayCert("请填写您的支付宝公钥证书文件路径,例如:d:/alipayCertPublicKey_RSA2.crt");
aliPayConfigStorage.setAliPayRootCert("请填写您的支付宝根证书文件路径,例如:d:/alipayRootCert.crt");
aliPayConfigStorage.setNotifyUrl("异步回调地址");
aliPayConfigStorage.setReturnUrl("同步回调地址");
aliPayConfigStorage.setSignType("签名方式");
aliPayConfigStorage.setSeller("收款账号");
aliPayConfigStorage.setInputCharset("utf-8");
//是否为测试账号,沙箱环境
aliPayConfigStorage.setTest(true);

```


#### 网络请求配置
Expand Down Expand Up @@ -85,7 +109,7 @@
```java

//支付订单基础信息
PayOrder payOrder = new PayOrder("订单title", "摘要", new BigDecimal(0.01) , UUID.randomUUID().toString().replace("-", ""));
PayOrder payOrder = new PayOrder("订单title", "摘要", BigDecimal.valueOf(0.01) , UUID.randomUUID().toString().replace("-", ""));

```

Expand Down Expand Up @@ -236,7 +260,7 @@
RefundOrder order = new RefundOrder("支付宝单号", "我方系统单号", "退款金额", "订单总金额");
//非必填, 根据业务需求而定,可用于多次退款
order.setRefundNo("退款单号")
Map result = service.refund(order);
AliRefundResult result = service.refund(order);

```

Expand Down
8 changes: 6 additions & 2 deletions pay-java-ali/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>pay-java-parent</artifactId>
<groupId>com.egzosn</groupId>
<version>2.13.2</version>
<version>2.13.3</version>
</parent>
<modelVersion>4.0.0</modelVersion>
<artifactId>pay-java-ali</artifactId>
Expand All @@ -19,7 +19,11 @@
<artifactId>pay-java-common</artifactId>
</dependency>
<!-- /pay-java -->

<dependency>
<groupId>org.bouncycastle</groupId>
<artifactId>bcprov-jdk15on</artifactId>
<version>1.59</version>
</dependency>
</dependencies>


Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,30 @@
package com.egzosn.pay.ali.api;

import java.io.IOException;
import java.io.InputStream;

import com.egzosn.pay.ali.bean.CertEnvironment;
import com.egzosn.pay.common.api.BasePayConfigStorage;
import com.egzosn.pay.common.api.CertStore;
import com.egzosn.pay.common.bean.result.PayException;
import com.egzosn.pay.common.exception.PayErrorException;

/**
* 支付配置存储
*
* @author egan
* <p>
* email [email protected]
* date 2016-5-18 14:09:01
* <p>
* email [email protected]
* date 2016-5-18 14:09:01
* </p>
* 以下证书签名相关触发前提是 {@link BasePayConfigStorage#isCertSign}等于true的情况。不然走的就是普通的方式
*/
public class AliPayConfigStorage extends BasePayConfigStorage {

/**
* ISV代商户代用,指定appAuthToken
*/
private String appAuthToken;
/**
* 商户应用id
*/
Expand All @@ -27,6 +40,39 @@ public class AliPayConfigStorage extends BasePayConfigStorage {
private String seller;


/**
* 应用公钥证书
*/
private Object merchantCert;

/**
* 支付宝公钥证书
*/
private Object aliPayCert;
/**
* 支付宝CA证书,根证书
*/
private Object aliPayRootCert;

/**
* 证书存储类型
*/
private CertStore certStoreType;

/**
* 证书信息
*/
private CertEnvironment certEnvironment;


public String getAppAuthToken() {
return appAuthToken;
}

public void setAppAuthToken(String appAuthToken) {
this.appAuthToken = appAuthToken;
}

public void setAppid(String appid) {
this.appid = appid;
}
Expand Down Expand Up @@ -55,5 +101,61 @@ public void setSeller(String seller) {
this.seller = seller;
}

public Object getMerchantCert() {
return merchantCert;
}

public void setMerchantCert(Object merchantCert) {
this.merchantCert = merchantCert;
}

public Object getAliPayCert() {
return aliPayCert;
}

public void setAliPayCert(Object aliPayCert) {
this.aliPayCert = aliPayCert;
}

public Object getAliPayRootCert() {
return aliPayRootCert;
}

public void setAliPayRootCert(Object aliPayRootCert) {
this.aliPayRootCert = aliPayRootCert;
}

public CertStore getCertStoreType() {
return certStoreType;
}

public void setCertStoreType(CertStore certStoreType) {
this.certStoreType = certStoreType;
}

public CertEnvironment getCertEnvironment() {
return certEnvironment;
}

public void setCertEnvironment(CertEnvironment certEnvironment) {
this.certEnvironment = certEnvironment;
}

/**
* 初始化证书信息
*/
public void loadCertEnvironment() {
if (!isCertSign() || null != this.certEnvironment) {
return;
}
try (InputStream merchantCertStream = certStoreType.getInputStream(merchantCert);
InputStream aliPayCertStream = certStoreType.getInputStream(aliPayCert);
InputStream aliPayRootCertStream = certStoreType.getInputStream(aliPayRootCert)) {
this.certEnvironment = new CertEnvironment(merchantCertStream, aliPayCertStream, aliPayRootCertStream);
} catch (IOException e) {
throw new PayErrorException(new PayException("读取证书异常", e.getMessage()));
}
}


}
Loading

0 comments on commit 7cc3488

Please sign in to comment.