Java SDK
获取SDK
方法一:Maven仓库方式
添加 repository
在pom.xml文件中添加仓库地址- releases地址:http://hcnnexus.bsoft.com.cn/repository/maven-public/
- snapshots地址:http://hcnnexus.bsoft.com.cn/repository/maven-snapshots/
<repositories> <repository> <id>hcnnexus-releases</id> <url>http://hcnnexus.bsoft.com.cn/repository/maven-public/</url> </repository> <repository> <id>hcnnexus-snapshots</id> <url>http://hcnnexus.bsoft.com.cn/repository/maven-snapshots/</url> </repository> </repositories>
添加 dependency
在pom.xml文件中添加依赖<dependency> <groupId>cn.com.bsoft.payment</groupId> <artifactId>payment-client-sdk</artifactId> <version>1.0.0</version> </dependency>
方法二:直接使用JAR文件方式
下载 JAVA SDK 1.0.0 解压后,将payment-client-sdk-1.0.0.jar
加入项目
SDK使用说明
构建PaymentClient
private static String DefaultOfflineURL = "http://pay.bsoftpay.com:53501/gatewayOffline/pay/offline/";
private static String TestOfflineURL = "http://offlinetest.bsoftpay.com:50001/gatewayOffline/pay/offline/";
static String PayType = "2";//2支付宝 3微信
static String MerchantNo = "809900000001";
public static void main(String[] argv) {
PaymentClient paymentClient = PaymentClientBuilder
.builder()
.url(TestOfflineURL)
.loadFrom(P7001Demo.class.getResourceAsStream("/66810.txt"))
.buildOffline();
FuncP7001(paymentClient);
}
构建RequestDTO对象
P7001Request p7001 = new P7001Request();
p7001.setTreatmentId("20140352");
p7001.setMerchantNo(MerchantNo);
p7001.setPayType(PayType);
p7001.setTradeType("1");
p7001.setOrderNo(orderNo);
p7001.setAmt(new BigDecimal("0.01"));
p7001.setSpbillCreateIP("192.168.10.228");
p7001.setOrderSubject("挂号单据");
p7001.setOrderDetail("挂号单据");
p7001.setRemark("");
p7001.setPayTimeOut(6);
执行Request获得Response对象
P7001Response p7001Response = paymentClient.execute(p7001);
OnlineClient范例
public class P7005Demo {
static String onlineTestUrl = "http://onlinetest.bsoftpay.com/gatewayOnline/gateway/portal/";
public static void main(String[] argv){
PaymentClient paymentClient = PaymentClientBuilder
.builder()
.url(onlineTestUrl)
.loadFrom(P7005Demo.class.getResourceAsStream("/66810.txt"))
.buildOnline();
P7005(paymentClient);
}
public static void P7005(PaymentClient paymentClient){
P7005Request req = new P7005Request();
req.setSubMerchant("小二");
...
Object rsp = paymentClient.execute(req);
System.out.println(MapperUtils.writeValueAsXML(rsp));
}
}
SDK DEMO项目
文档更新时间: 2022-11-11 10:49 作者:甘世敏