# jlpay-sdk-java-lib **Repository Path**: jlpaydemo/jlpay-sdk-java-lib ## Basic Information - **Project Name**: jlpay-sdk-java-lib - **Description**: 咕朵云开放平台sdk-lib - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 2 - **Forks**: 1 - **Created**: 2025-07-14 - **Last Updated**: 2026-06-01 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README ### 功能 为第三方提供商户进件、文件上传、交易接入开放平台等功能的OpenAPI SDK ### 使用方法 1. 在项目的pom.xml中引入OpenAPI的SDK ```xml com.jlpay open-jlpay-sdk-java 1.0.21 ``` 2. 使用OpenAPI的SDK sdk封装了调用OpenAPI的Service: | Service | Config 类 | 说明 | |---|---|---| | `JlpayOrgService` | `OrgConfig` | 业务接口 | | `JlpayUploadFileService` | `OrgConfig` | 文件上传 | | `JlpayNotifyParseService` | `NotifyConfig` | 回调通知验签 | 此处给出JlpayOrgService和JlpayNotifyParseService简单的示例: ```java import com.jlpay.open.jlpay.sdk.java.config.NotifyConfig; import com.jlpay.open.jlpay.sdk.java.config.OrgConfig; import com.jlpay.open.jlpay.sdk.java.service.JlpayNotifyParseService; import com.jlpay.open.jlpay.sdk.java.service.JlpayOrgService; import com.jlpay.open.jlpay.sdk.java.http.DefaultHttpClientBuilder; public class JlpayOpenApiService { /** * pem格式的机构私钥 */ private static final String ORG_PRIVATE_KEY = "***"; /** * pem格式的嘉联公钥 */ private static final String JLPAY_PUBLIC_KEY = "***"; /** * 应用ID */ private static final String APP_ID = "***"; /** * URL */ private static final String URL = "https://openapi-uat.jlpay.com"; private static final JlpayOrgService jlpayOrgService = createJlpayOrgService(); private static final JlpayNotifyParseService jlpayNotifyParseService = createJlpayNotifyParseService(); private JlpayOpenApiService() { throw new IllegalStateException("Utility class"); } private static JlpayOrgService createJlpayOrgService() { OrgConfig orgConfig = OrgConfig.builder() .appId(APP_ID) .url(URL) .orgPriKey(ORG_PRIVATE_KEY) .jlpayPubKey(JLPAY_PUBLIC_KEY) .verifyOrgNo(false) .verifyMerchNo(false) .build(); return new JlpayOrgService.Builder() .config(orgConfig) // 可以自定义HttpClient, 也可以不传, 默认使用DefaultHttpClientBuilder .httpClient(new DefaultHttpClientBuilder() .config(orgConfig) .connectTimeoutMills(3000) .readTimeoutMills(5000) .writeTimeoutMills(5000) .build()) .build(); } private static JlpayNotifyParseService createJlpayNotifyParseService() { NotifyConfig config = NotifyConfig.builder() .jlpayPubKey(JLPAY_PUBLIC_KEY) .build(); return new JlpayNotifyParseService.Builder().config(config).build(); } public static JlpayOrgService service() { return jlpayOrgService; } public static JlpayNotifyParseService notifyParseService() { return jlpayNotifyParseService; } } ``` 1.0.2版本,新增对使用SM2WithSM4加密算法的请求报文进行敏感字段的自动加密和响应报文的敏感字段进行自动解密 ```plain 使用SM2WithSM4加密算法即orgConfig.cryptoAlg("SM2WithSM4") 1. 默认不自动生成对称加密密钥和不自动对请求报文的敏感字段进行加密 如果需要开启,设置orgConfig.autoEncrypt(Boolean.TRUE) 如果不开启自动加密,可参考以下代码进行手动加密 1) 并通过以下方法生成SM4对称加密密钥 String key = KeyGenerateUtils.generateSm4Key(32 * 4); 2) 然后请求类设置SM2算法加密后的SM4对称加密密钥 String encryptedKey = CryptoHelper.encryptWithSm2(key, config.getJlpayPubKey()); request.setCryptoKey(encryptedKey); 3) 最后对请求报文的敏感字段进行加密 request.setXxx(CryptoHelper.encryptWithSm4(xxx, key)); 2. 默认不自动对响应报文的敏感字段进行解密 如果需要开启,设置orgConfig.autoDecrypt(Boolean.TRUE) 如果不开启自动解密,可参考以下代码进行手动解密 通过JlpayOrgService.post(request)方法获取HttpResponse 然后从HttpResponse获取响应头x-jlpay-key和x-jlpay-crypto-alg 1) SM2算法解密SM4对称加密密钥 String key = CryptoHelper.decryptWithSm2(encryptedKey, config.getOrgPriKey()); 2) SM4算法解密敏感字段 String plaintext = CryptoHelper.decryptWithSm4(cipherText, key); ``` ### 其他 签名规则采用[开放接口统一签名方式](https://jlpay.yuque.com/fsx9z5/regckm/gk8uuowzqv938qcp)V5版本