### Payment API Integration Example Source: https://github.com/yunzhanghuopen/sdk-java/blob/master/README.md Demonstrates how to configure the SDK and perform a bank card real-time order request. ```java import com.yunzhanghu.sdk.base.YzhConfig; import com.yunzhanghu.sdk.base.YzhConfig.SignType; import com.yunzhanghu.sdk.base.YzhRequest; import com.yunzhanghu.sdk.base.YzhResponse; import com.yunzhanghu.sdk.payment.PaymentClient; import com.yunzhanghu.sdk.payment.domain.CreateBankpayOrderRequest; import com.yunzhanghu.sdk.payment.domain.CreateBankpayOrderResponse; import org.junit.Assert; import org.junit.Test; // 接口调用示例 public class Payment { // 银行卡实时下单接口 @Test public void bankCardOrder() { try { YzhConfig config = getYzhConfig(); PaymentClient client = new PaymentClient(config); // 设置连接超时时间,默认 30S client.setSocketTimeout(30*1000);// 单位:毫秒 CreateBankpayOrderRequest request = new CreateBankpayOrderRequest(); request.setOrderId("202009010016562012987"); request.setDealerId(config.getDealerId()); request.setBrokerId(config.getBrokerId()); request.setRealName("张三"); request.setCardNo("6228888888888888888"); request.setPhoneNo("188****8888"); request.setIdCard("11010519491231002X"); request.setPay("100.00"); request.setPayRemark(""); request.setNotifyUrl("https://www.example.com"); // 调用银行卡实时下单接口 YzhResponse response = client.createBankpayOrder(YzhRequest.build(request)); System.out.println(response); Assert.assertTrue(response.isSuccess()); CreateBankpayOrderResponse data = response.getData(); System.out.println(data); } catch (Exception e) { e.printStackTrace(); } } // 获取基础配置 private static YzhConfig getYzhConfig() { YzhConfig config = new YzhConfig(); // 方式一:从配置文件获取 // config = YzhConfig.loadConfig("yzh.properties"); // 方式二:自定义配置 config.setDealerId(""); config.setBrokerId(""); config.setSignType(SignType.RSA); config.setYzh3DesKey(""); config.setYzhAppKey(""); config.setYzhRsaPrivateKey(""); config.setYzhRsaPublicKey(""); config.setYzhUrl("https://api-service.yunzhanghu.com"); return config; } } ``` -------------------------------- ### Maven Dependency Configuration Source: https://github.com/yunzhanghuopen/sdk-java/blob/master/README.md Add this dependency to your project's pom.xml file to use the SDK. ```xml com.yunzhanghu.openapi sdk 1.4.40-RELEASE ``` -------------------------------- ### Generate RSA Keys with OpenSSL Source: https://github.com/yunzhanghuopen/sdk-java/blob/master/README.md Commands to generate private and public keys for secure communication. ```bash ① ⽣成私钥 private_key.pem OpenSSL-> genrsa -out private_key.pem 2048 // 建议密钥⻓度⾄少为 2048 位 OpenSSL-> pkcs8 -topk8 -inform PEM -in private_key.pem -outform PEM -nocrypt -out private_key_pkcs8.pem // 将私钥转为 PKCS8 格式 ② ⽣成公钥⽂件 pubkey.pem OpenSSL-> rsa -in private_key.pem -pubout -out pubkey.pem ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.