diff --git a/README.md b/README.md index 77bbf69..f9c5b84 100644 --- a/README.md +++ b/README.md @@ -45,7 +45,7 @@ Starter,支持微信优惠券,代金券、商家券、智慧商圈、商家 cn.felord payment-spring-boot-starter - 1.0.19.RELEASE + 1.0.20.RELEASE ``` diff --git a/docs/README.md b/docs/README.md index fcedd7a..df92a5c 100644 --- a/docs/README.md +++ b/docs/README.md @@ -35,7 +35,7 @@ cn.felord payment-spring-boot-starter - 1.0.19.RELEASE + 1.0.20.RELEASE ``` ## 采用技术 @@ -51,4 +51,4 @@ ## **免责声明** -**本项目涉及到资金交易开发,开发者需要经严格测试后方能用于生产环境,本项目不对使用者的行为负责。** \ No newline at end of file +**本项目涉及到资金交易开发,开发者需要经严格测试后方能用于生产环境,本项目不对使用者的行为负责。** diff --git a/docs/quick_start.md b/docs/quick_start.md index e9d853d..768dff4 100644 --- a/docs/quick_start.md +++ b/docs/quick_start.md @@ -4,7 +4,7 @@ cn.felord payment-spring-boot-starter - 1.0.19.RELEASE + 1.0.20.RELEASE ``` > 基于 **Spring Boot 2.x** @@ -174,4 +174,4 @@ public class PayConfig { System.out.println("execute = " + execute.getBody()); } -``` \ No newline at end of file +``` diff --git a/payment-spring-boot-autoconfigure/pom.xml b/payment-spring-boot-autoconfigure/pom.xml index 89ed791..86214da 100644 --- a/payment-spring-boot-autoconfigure/pom.xml +++ b/payment-spring-boot-autoconfigure/pom.xml @@ -22,11 +22,11 @@ cn.felord payment-spring-boot - 1.0.19.RELEASE + 1.0.20.RELEASE payment-spring-boot-autoconfigure - 1.0.19.RELEASE + 1.0.20.RELEASE jar 4.0.0 @@ -92,4 +92,4 @@ - \ No newline at end of file + diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/BusinessCertType.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/BusinessCertType.java new file mode 100644 index 0000000..ff4e0c1 --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/enumeration/BusinessCertType.java @@ -0,0 +1,71 @@ +/* + * Copyright 2019-2022 felord.cn + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * Website: + * https://felord.cn + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.felord.payment.wechat.enumeration; + +/** + * The enum Business cert type. + * + * @author dax + * @since 2023 /7/1 8:34 + */ +public enum BusinessCertType { + /** + * 事业单位法人证书 + */ + CERTIFICATE_TYPE_2388, + + /** + * 统一社会信用代码证书 + */ + CERTIFICATE_TYPE_2389, + + /** + * 社会团体法人登记证书 + */ + CERTIFICATE_TYPE_2394, + /** + * 民办非企业单位登记证书 + */ + CERTIFICATE_TYPE_2395, + + /** + * 基金会法人登记证书 + */ + CERTIFICATE_TYPE_2396, + /** + * 宗教活动场所登记证 + */ + CERTIFICATE_TYPE_2399, + + /** + * 政府部门下发的其他有效证明文件 + */ + CERTIFICATE_TYPE_2400, + /** + * 执业许可证/执业证 + */ + CERTIFICATE_TYPE_2520, + /** + * 基层群众性自治组织特别法人统一社会信用代码证 + */ + CERTIFICATE_TYPE_2521, + /** + * 农村集体经济组织登记证 + */ + CERTIFICATE_TYPE_2522 +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/AbstractApi.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/AbstractApi.java index 44da479..26a6a50 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/AbstractApi.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/AbstractApi.java @@ -31,6 +31,9 @@ import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.node.ObjectNode; import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateSerializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer; +import com.fasterxml.jackson.datatype.jsr310.ser.LocalTimeSerializer; import org.springframework.core.io.Resource; import org.springframework.http.ContentDisposition; import org.springframework.http.HttpHeaders; @@ -44,6 +47,8 @@ import org.springframework.web.util.UriComponentsBuilder; import java.net.URI; import java.time.LocalDate; +import java.time.LocalDateTime; +import java.time.LocalTime; import java.time.format.DateTimeFormatter; import java.util.Objects; import java.util.Optional; @@ -92,12 +97,16 @@ public abstract class AbstractApi { * @param mapper the mapper */ private void applyObjectMapper(ObjectMapper mapper) { + JavaTimeModule javaTimeModule = new JavaTimeModule(); + javaTimeModule.addSerializer(LocalDate.class, new LocalDateSerializer(DateTimeFormatter.ISO_LOCAL_DATE)); + javaTimeModule.addSerializer(LocalDateTime.class, new LocalDateTimeSerializer(DateTimeFormatter.ISO_LOCAL_DATE_TIME)); + javaTimeModule.addSerializer(LocalTime.class, new LocalTimeSerializer(DateTimeFormatter.ISO_LOCAL_TIME)); mapper.setPropertyNamingStrategy(PropertyNamingStrategy.SNAKE_CASE) .configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false) // empty string error .configure(DeserializationFeature.ACCEPT_EMPTY_STRING_AS_NULL_OBJECT, true) .setSerializationInclusion(JsonInclude.Include.NON_NULL) - .registerModule(new JavaTimeModule()); + .registerModule(javaTimeModule); } diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/SignatureProvider.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/SignatureProvider.java index c683574..b949cd6 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/SignatureProvider.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/SignatureProvider.java @@ -184,15 +184,15 @@ public class SignatureProvider { .orElseThrow(() -> new PayException("cannot obtain the certificate")); }); - try { - final String signatureStr = createSign(params.getWechatpayTimestamp(), params.getWechatpayNonce(), params.getBody()); - Signature signer = Signature.getInstance("SHA256withRSA", BC_PROVIDER); - signer.initVerify(certificate.getX509Certificate()); - signer.update(signatureStr.getBytes(StandardCharsets.UTF_8)); - return signer.verify(Base64Utils.decodeFromString(params.getWechatpaySignature())); - }catch (Exception e){ - throw new PayException("An exception occurred during the response verification, the cause: "+e.getMessage()); - } + try { + final String signatureStr = createSign(params.getWechatpayTimestamp(), params.getWechatpayNonce(), params.getBody()); + Signature signer = Signature.getInstance("SHA256withRSA", BC_PROVIDER); + signer.initVerify(certificate.getX509Certificate()); + signer.update(signatureStr.getBytes(StandardCharsets.UTF_8)); + return signer.verify(Base64Utils.decodeFromString(params.getWechatpaySignature())); + } catch (Exception e) { + throw new PayException("An exception occurred during the response verification, the cause: " + e.getMessage()); + } } @@ -230,12 +230,9 @@ public class SignatureProvider { throw new PayException("cant obtain the response body"); } ArrayNode certificates = bodyObjectNode.withArray("data"); - if (certificates.isArray() && certificates.size() > 0) { - CERTIFICATE_SET.forEach(x509WechatCertificateInfo -> { - if (Objects.equals(tenantId, x509WechatCertificateInfo.getTenantId())) { - CERTIFICATE_SET.remove(x509WechatCertificateInfo); - } - }); + if (certificates.isArray() && !certificates.isEmpty()) { + CERTIFICATE_SET.removeIf(x509WechatCertificateInfo -> + Objects.equals(tenantId, x509WechatCertificateInfo.getTenantId())); final CertificateFactory certificateFactory = CertificateFactory.getInstance("X509", BC_PROVIDER); certificates.forEach(objectNode -> { JsonNode encryptCertificate = objectNode.get("encrypt_certificate"); diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMarketingFavorApi.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMarketingFavorApi.java index b97ea48..68f2b07 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMarketingFavorApi.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatMarketingFavorApi.java @@ -158,7 +158,9 @@ public class WechatMarketingFavorApi extends AbstractApi { WechatPayProperties.V3 v3 = this.wechatMetaBean().getV3(); params.setAppid(v3.getAppId()); - params.setStockCreatorMchid(v3.getMchId()); + if (StringUtils.hasText(params.getStockCreatorMchid())){ + params.setStockCreatorMchid(v3.getMchId()); + } URI uri = UriComponentsBuilder.fromHttpUrl(type.uri(WeChatServer.CHINA)) .build() .expand(params.getOpenid()) diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayScoreParkingApi.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayScoreParkingApi.java index 4bc3396..16f35ae 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayScoreParkingApi.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/WechatPayScoreParkingApi.java @@ -76,6 +76,7 @@ public class WechatPayScoreParkingApi extends AbstractApi { URI uri = UriComponentsBuilder.fromHttpUrl(wechatPayV3Type.uri(WeChatServer.CHINA)) .queryParams(queryParams) + .encode() .build() .toUri(); return Get(uri); diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/batchtransfer/CreateBatchTransferParams.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/batchtransfer/CreateBatchTransferParams.java index 40f0327..6c82d6d 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/batchtransfer/CreateBatchTransferParams.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/batchtransfer/CreateBatchTransferParams.java @@ -61,6 +61,11 @@ public class CreateBatchTransferParams { * 指定该笔转账使用的转账场景ID */ private String transferSceneId; + /** + * 回调通知 + * @since 1.0.20 + */ + private String notifyUrl; /** * 转账明细. @@ -96,4 +101,4 @@ public class CreateBatchTransferParams { */ private String userIdCard; } -} \ No newline at end of file +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/ecommerce/EcommerceBusinessLicenseInfo.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/ecommerce/EcommerceBusinessLicenseInfo.java index acf0b99..081292b 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/ecommerce/EcommerceBusinessLicenseInfo.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/ecommerce/EcommerceBusinessLicenseInfo.java @@ -17,6 +17,7 @@ package cn.felord.payment.wechat.v3.model.ecommerce; +import cn.felord.payment.wechat.enumeration.BusinessCertType; import lombok.Data; /** @@ -25,6 +26,7 @@ import lombok.Data; */ @Data public class EcommerceBusinessLicenseInfo { + private BusinessCertType certType; private String businessLicenseCopy; private String businessLicenseNumber; private String merchantName; diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/ecommerce/EcommerceContactInfo.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/ecommerce/EcommerceContactInfo.java index 895f40a..850ed0e 100644 --- a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/ecommerce/EcommerceContactInfo.java +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/ecommerce/EcommerceContactInfo.java @@ -28,9 +28,9 @@ public class EcommerceContactInfo { private String contactIdCardNumber; private String contactIdDocCopy; private String contactIdDocCopyBack; - private String contactIdDocPeriodBegin; private String contactIdDocPeriodEnd; private String businessAuthorizationLetter; + private String contactIdDocPeriodBegin; private String mobilePhone; private String contactEmail; -} \ No newline at end of file +} diff --git a/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/ecommerce/UboInfoListItem.java b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/ecommerce/UboInfoListItem.java new file mode 100644 index 0000000..04fe0b2 --- /dev/null +++ b/payment-spring-boot-autoconfigure/src/main/java/cn/felord/payment/wechat/v3/model/ecommerce/UboInfoListItem.java @@ -0,0 +1,35 @@ +/* + * Copyright 2019-2022 felord.cn + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * https://www.apache.org/licenses/LICENSE-2.0 + * Website: + * https://felord.cn + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ + +package cn.felord.payment.wechat.v3.model.ecommerce; + +import cn.felord.payment.wechat.enumeration.IdDocType; +import lombok.Data; + +import java.time.LocalDate; + +@Data +public class UboInfoListItem { + private IdDocType uboIdDocType; + private String uboIdDocCopy; + private String uboIdDocCopyBack; + private String uboIdDocName; + private String uboIdDocNumber; + private String uboIdDocAddress; + private LocalDate uboIdDocPeriodBegin; + private String uboIdDocPeriodEnd; +} \ No newline at end of file diff --git a/payment-spring-boot-starter/pom.xml b/payment-spring-boot-starter/pom.xml index f593105..52620ab 100644 --- a/payment-spring-boot-starter/pom.xml +++ b/payment-spring-boot-starter/pom.xml @@ -22,11 +22,11 @@ cn.felord payment-spring-boot - 1.0.19.RELEASE + 1.0.20.RELEASE payment-spring-boot-starter - 1.0.19.RELEASE + 1.0.20.RELEASE jar 4.0.0 @@ -62,4 +62,4 @@ - \ No newline at end of file + diff --git a/pom.xml b/pom.xml index 448adcb..6c5cd3b 100644 --- a/pom.xml +++ b/pom.xml @@ -21,7 +21,7 @@ xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> cn.felord payment-spring-boot - 1.0.19.RELEASE + 1.0.20.RELEASE pom 4.0.0 @@ -90,7 +90,7 @@ 1.8 2.7.7 4.31.7.ALL - 1.69 + 1.74 @@ -212,4 +212,4 @@ - \ No newline at end of file +