update huifu

This commit is contained in:
2023-04-17 15:49:02 +08:00
parent d968a9bada
commit 5ff9943688
12 changed files with 3090 additions and 0 deletions

View File

@@ -77,6 +77,16 @@
<groupId>com.fasterxml.jackson.dataformat</groupId>
<artifactId>jackson-dataformat-avro</artifactId>
</dependency>
<dependency>
<groupId>com.huifu.adapay.core</groupId>
<artifactId>adapay-core-sdk</artifactId>
</dependency>
<dependency>
<groupId>com.huifu.adapay</groupId>
<artifactId>adapay-java-sdk</artifactId>
</dependency>
</dependencies>
<properties>

View File

@@ -0,0 +1,134 @@
package com.jsowell.adapay.demo;
import com.alibaba.fastjson.JSON;
import com.huifu.adapay.model.AdapayTools;
import com.huifu.adapay.model.Bill;
import com.huifu.adapay.model.Wallet;
import java.util.HashMap;
import java.util.Map;
/**
* @author yingyong.wang
*/
public class AdapayToolsDemo extends com.huifu.adapay.demo.BaseDemo {
/**
* 获取银联用户号
*
* @throws Exception 异常
*/
public static void executeToolsTest(String appId, String merchantKey) throws Exception {
Map<String, Object> unionParam = new HashMap<String, Object>(2);
unionParam.put("order_no", "20190912");
unionParam.put("app_id", appId);
unionParam.put("user_auth_code", "20190912");
unionParam.put("app_up_identifier", "20190912");
Map<String, Object> result = AdapayTools.unionUserId(unionParam, merchantKey);
String errorCode = (String) result.get("error_code");
if (null != errorCode) {
System.out.println("对账单下载,请求参数:" + JSON.toJSONString(unionParam));
System.out.println("对账单下载,返回参数:" + JSON.toJSONString(result));
} else {
System.out.println("对账单下载,成功");
}
}
/**
* 获取银联用户号
*
* @throws Exception 异常
*/
public static void executeToolsTest(String appId) throws Exception {
Map<String, Object> unionParam = new HashMap<String, Object>(2);
unionParam.put("order_no", "jsdk_payment_" + System.currentTimeMillis());
unionParam.put("app_id", appId);
unionParam.put("user_auth_code", "5yRGbi+IRda5khIQoQf1Hw==");
unionParam.put("app_up_identifier", "CloudPay");
Map<String, Object> result = AdapayTools.unionUserId(unionParam);
System.out.println("获取银联云闪付用户标识:" + JSON.toJSONString(result));
String errorCode = (String) result.get("error_code");
if (null != errorCode) {
System.out.println("获取银联云闪付用户标识,请求参数:" + JSON.toJSONString(unionParam));
System.out.println("获取银联云闪付用户标识,返回参数:" + JSON.toJSONString(result));
} else {
System.out.println("获取银联云闪付用户标识,成功");
}
}
/**
* 钱包登录申请
*
* @throws Exception 异常
*/
public static void executeLoginTest(String appId, String merchantKey) throws Exception {
Map<String, Object> queryParams = new HashMap<String, Object>(5);
queryParams.put("ip", "127.0.0.1");
queryParams.put("member_id", "0");
//queryParams.put("member_id", "iris1234_14151");
queryParams.put("app_id", appId);
Map<String, Object> login = Wallet.login(queryParams, merchantKey);
if (login != null && "succeeded".equals(login.get("status"))) {
String formString = login.get("redirect_url").toString();
System.out.println("跳转地址:" + formString);
}
}
/**
* 钱包登录申请
*
* @throws Exception 异常
*/
public static void executeLoginTest(String appId) throws Exception {
Map<String, Object> queryParams = new HashMap<String, Object>(5);
queryParams.put("ip", "127.0.0.1");
queryParams.put("member_id", "0");
//queryParams.put("member_id", "iris1234_14151");
queryParams.put("app_id", appId);
Map<String, Object> login = Wallet.login(queryParams);
if (login != null && "succeeded".equals(login.get("status"))) {
String formString = login.get("redirect_url").toString();
System.out.println("跳转地址:" + formString);
}
}
/**
* 执行一个下载对账文件操作
*
* @return 下载链接
* @throws Exception 异常
*/
public Map<String, Object> executeBillDownLoad() throws Exception {
Map<String, Object> downloadParam = new HashMap<String, Object>(2);
downloadParam.put("bill_date", "20190912");
Map<String, Object> download = Bill.download(downloadParam);
String errorCode = (String) download.get("error_code");
if (null != errorCode) {
System.out.println("对账单下载,请求参数:" + JSON.toJSONString(downloadParam));
System.out.println("对账单下载,返回参数:" + JSON.toJSONString(download));
} else {
System.out.println("对账单下载,成功");
}
return download;
}
}

View File

@@ -0,0 +1,7 @@
package com.huifu.adapay.demo;
/**
* @author jane.zhao
*/
public class BaseDemo {
}

View File

@@ -0,0 +1,90 @@
package com.huifu.adapay.demo;
import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.huifu.adapay.model.AdapayTools;
import com.huifu.adapay.model.Bill;
/**
* @author yingyong.wang
*/
public class BillDemo extends BaseDemo{
/**
* 运行账单下载接口
* @throws Exception 异常
*/
public static void executeBillTest(String merchantKey) throws Exception{
BillDemo demo = new BillDemo();
Map<String, Object> download = demo.executeBillDownLoad(merchantKey);
}
/**
* 运行账单下载接口
* @throws Exception 异常
*/
public static void executeBillTest() throws Exception{
BillDemo demo = new BillDemo();
Map<String, Object> download = demo.executeBillDownLoad();
}
/**
* 执行一个下载对账文件操作
* @return 下载链接
* @throws Exception 异常
*/
public Map<String, Object> executeBillDownLoad(String merchantKey) throws Exception {
System.out.println("=======execute download begin=======");
Map<String, Object> downloadParam = new HashMap<String, Object>(2);
downloadParam.put("bill_date", "20190912");
Map<String, Object> download = Bill.download(downloadParam, merchantKey);
String errorCode = (String)download.get("error_code");
if(null != errorCode){
System.out.println("对账单下载,请求参数:" + JSON.toJSONString(downloadParam));
System.out.println("对账单下载,返回参数:" + JSON.toJSONString(download));
}else{
System.out.println("对账单下载,成功");
}
return download;
}
/**
* 执行一个下载对账文件操作
* @return 下载链接
* @throws Exception 异常
*/
public Map<String, Object> executeBillDownLoad() throws Exception {
Map<String, Object> downloadParam = new HashMap<String, Object>(2);
downloadParam.put("bill_date", "20190912");
Map<String, Object> download = AdapayTools.downloadBill(downloadParam);
String errorCode = (String)download.get("error_code");
if(null != errorCode){
System.out.println("对账单下载,请求参数:" + JSON.toJSONString(downloadParam));
System.out.println("对账单下载,返回参数:" + JSON.toJSONString(download));
}else{
System.out.println("对账单下载,成功");
}
return download;
}
}

View File

@@ -0,0 +1,173 @@
package com.huifu.adapay.demo;
import java.io.File;
import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.huifu.adapay.model.CorpMember;
/**
* @author yingyong.wang
*/
public class CorpMemberDemo extends BaseDemo {
/**
* 运行 CorpMember 类接口
*
* @throws Exception 异常
*/
public static void executeCorpMemberTest(String merchantKey, String app_id) throws Exception {
CorpMemberDemo demo = new CorpMemberDemo();
Map<String, Object> member = demo.executeCreateMember(merchantKey, app_id);
demo.executeQueryMember(merchantKey, (String) member.get("member_id"), app_id);
}
/**
* 创建 CorpMember
*
* @return 创建的CorpMember 对象
* @throws Exception 异常
*/
public Map<String, Object> executeCreateMember(String merchantKey, String app_id) throws Exception {
System.out.println("=======execute Create CorpMember begin=======");
Map<String, Object> memberParams = new HashMap<String, Object>(2);
memberParams.put("member_id", "jsdk_member_" + System.currentTimeMillis());
memberParams.put("app_id", app_id);
memberParams.put("order_no", "jsdk_order_" + System.currentTimeMillis());
memberParams.put("social_credit_code_expires", "1111");
memberParams.put("business_scope", "123");
memberParams.put("name", "中国测试有限公司");
memberParams.put("prov_code", "0011");
memberParams.put("area_code", "1100");
memberParams.put("social_credit_code", "201932658452655");
memberParams.put("legal_person", "张测试");
memberParams.put("legal_cert_id", "321485199014234852");
memberParams.put("legal_cert_id_expires", "20220112");
memberParams.put("legal_mp", "13958465215");
memberParams.put("address", "中国上海");
memberParams.put("zip_code", "225485");
memberParams.put("telphone", "41164452");
memberParams.put("email", "ceshi@qq.com");
memberParams.put("bank_code", "652142");
memberParams.put("bank_acct_type", "1");
memberParams.put("card_no", "622546895642156");
memberParams.put("card_name", "中国测试有限公司");
File file = new File("/Users/will/Project/Adapay/AdapayJava/AdapayDemo/src/main/java/com/huifu/adapay/demo/归档.zip");
System.out.println("创建企业用户,请求参数:" + JSON.toJSONString(memberParams) );
Map<String, Object> member = CorpMember.create(memberParams, file, merchantKey);
System.out.println("创建企业用户,返回参数:" + JSON.toJSONString(member) );
System.out.println("=======execute Create CorpMember end=======");
return member;
}
/**
* 查询 CorpMember
*
* @param member_id 待查询的member_id
* @return 查询的 CorpMember 对象
* @throws Exception 异常
*/
public Map<String, Object> executeQueryMember(String merchantKey, String member_id,String app_id) throws Exception {
System.out.println("=======execute query CorpMember begin=======");
Map<String, Object> memberParams = new HashMap<String, Object>(2);
memberParams.put("member_id", member_id);
memberParams.put("app_id", app_id);
System.out.println("查询企业用户,请求参数:"+JSON.toJSONString(memberParams));
Map<String, Object> member = CorpMember.query(memberParams, merchantKey);
System.out.println("查询企业用户,返回参数:"+JSON.toJSONString(member));
System.out.println("=======execute query CorpMember end=======");
return member;
}
/**
* 运行 CorpMember 类接口
*
* @throws Exception 异常
*/
public static void executeCorpMemberTest( String app_id) throws Exception {
CorpMemberDemo demo = new CorpMemberDemo();
Map<String, Object> member = demo.executeCreateMember( app_id);
demo.executeQueryMember( (String) member.get("member_id"), app_id);
}
/**
* 创建 CorpMember
*
* @return 创建的CorpMember 对象
* @throws Exception 异常
*/
public Map<String, Object> executeCreateMember( String app_id) throws Exception {
System.out.println("=======execute Create CorpMember begin=======");
Map<String, Object> memberParams = new HashMap<String, Object>(2);
memberParams.put("member_id", "jsdk_member_" + System.currentTimeMillis());
memberParams.put("app_id", app_id);
memberParams.put("order_no", "jsdk_order_" + System.currentTimeMillis());
memberParams.put("social_credit_code_expires", "1111");
memberParams.put("business_scope", "123");
memberParams.put("name", "中国测试有限公司");
memberParams.put("prov_code", "0011");
memberParams.put("area_code", "1100");
memberParams.put("social_credit_code", "201932658452655");
memberParams.put("legal_person", "张测试");
memberParams.put("legal_cert_id", "321485199014234852");
memberParams.put("legal_cert_id_expires", "20220112");
memberParams.put("legal_mp", "13958465215");
memberParams.put("address", "中国上海");
memberParams.put("zip_code", "225485");
memberParams.put("telphone", "41164452");
memberParams.put("email", "ceshi@qq.com");
memberParams.put("bank_code", "652142");
memberParams.put("bank_acct_type", "1");
memberParams.put("card_no", "622546895642156");
memberParams.put("card_name", "中国测试有限公司");
String path= CorpMemberDemo.class.getClassLoader().getResource("").getPath()+"test.zip";
File file = new File(path);
System.out.println("创建企业用户,请求参数:" + JSON.toJSONString(memberParams) );
Map<String, Object> member = CorpMember.create(memberParams, file);
System.out.println("创建企业用户,返回参数:" + JSON.toJSONString(member) );
System.out.println("=======execute Create CorpMember end=======");
return member;
}
/**
* 查询 CorpMember
*
* @param member_id 待查询的member_id
* @return 查询的 CorpMember 对象
* @throws Exception 异常
*/
public Map<String, Object> executeQueryMember( String member_id,String app_id) throws Exception {
System.out.println("=======execute query CorpMember begin=======");
Map<String, Object> memberParams = new HashMap<String, Object>(2);
memberParams.put("member_id", member_id);
memberParams.put("app_id", app_id);
System.out.println("查询企业用户请求参数1"+JSON.toJSONString(memberParams));
Map<String, Object> member = CorpMember.query(memberParams);
System.out.println("查询企业用户,返回参数:"+JSON.toJSONString(member));
System.out.println("=======execute query CorpMember end=======");
return member;
}
}

View File

@@ -0,0 +1,122 @@
package com.huifu.adapay.demo;
import com.alibaba.fastjson.JSON;
import com.huifu.adapay.model.FastPay;
import java.util.HashMap;
import java.util.Map;
/**
* @author gxw
* @date 2020-12-04
*/
public class FastPayDemo extends BaseDemo{
/**
* 运行 member 类接口
* @throws Exception 异常
*/
public static Map<String, Object> executeCardTest(String app_id) throws Exception{
FastPayDemo fastPayDemo = new FastPayDemo();
Map<String, Object> result = new HashMap<>();
result = fastPayDemo.executeCardApply(app_id);
result = fastPayDemo.executeCardConfirm(app_id);
result = fastPayDemo.executeCardList(app_id);
result = fastPayDemo.executeConfirm(app_id);
result = fastPayDemo.executeSendSms(app_id);
return result;
}
/**
* 创建快捷绑卡
* @return 创建快捷绑卡 对象
* @throws Exception 异常
*/
public Map<String, Object> executeCardApply(String app_id) throws Exception {
System.out.println("=======execute executeCardApply begin=======");
Map<String, Object> applyParam = new HashMap<String, Object>();
applyParam.put("app_id", app_id);
applyParam.put("member_id", "member_id_test");
applyParam.put("card_id", "666666666666666666666666");
applyParam.put("tel_no", "13888888888");
applyParam.put("vip_code", "321");
applyParam.put("expiration", "0225");
Map<String, Object> result = FastPay.cardApply(applyParam);
System.out.println("=======execute executeCardApply end=======");
return result;
}
/**
* 创建快捷绑卡确认
* @return 创建快捷绑卡确认 对象
* @throws Exception 异常
*/
public Map<String, Object> executeCardConfirm(String app_id) throws Exception {
System.out.println("=======execute executeCardConfirm begin=======");
Map<String, Object> confirmParam = new HashMap<String, Object>();
confirmParam.put("apply_id", app_id);
confirmParam.put("sms_code", "123456");
confirmParam.put("notify_url", "https://xxxx.com/xxxx");
Map<String, Object> result = FastPay.cardConfirm(confirmParam);
System.out.println("创建用户,返回参数:" + JSON.toJSONString(result));
System.out.println("=======execute executeCardConfirm end=======");
return result;
}
/**
* 查询快捷卡对象列表
* @return 查询快捷卡对象列表
* @throws Exception 异常
*/
public Map<String, Object> executeCardList( String app_id) throws Exception {
System.out.println("=======execute executeCardList begin=======");
Map<String, Object> listParam = new HashMap<String, Object>();
listParam.put("app_id", app_id);
listParam.put("member_id", "member_id_test");
listParam.put("token_no", "10000067502");
Map<String, Object> result = FastPay.cardList(listParam);
System.out.println("查询用户,返回参数:" + JSON.toJSONString(result));
System.out.println("=======execute executeCardList end=======");
return result;
}
/**
* 创建支付对象
* @return 创建支付对象
* @throws Exception 异常
*/
public Map<String, Object> executeConfirm( String app_id) throws Exception {
System.out.println("=======execute executeConfirm begin=======");
Map<String, Object> confirmParams = new HashMap<String, Object>();
confirmParams.put("payment_id", "002112020012010545810065165317376983040");
confirmParams.put("sms_code", "123456");
confirmParams.put("app_id", app_id);
Map<String, Object> result = FastPay.confirm(confirmParams);
System.out.println("=======execute executeConfirm end=======");
return result;
}
/**
* 创建快捷支付短信重发
* @return 创建快捷支付短信重发
* @throws Exception 异常
*/
public Map<String, Object> executeSendSms( String app_id) throws Exception {
System.out.println("=======execute executeSendSms begin=======");
Map<String, Object> smsCodeParam = new HashMap<String, Object>();
smsCodeParam.put("payment_id", "20190912");
Map<String, Object> result = FastPay.smsCode(smsCodeParam);
System.out.println("=======execute executeSendSms end=======");
return result;
}
}

View File

@@ -0,0 +1,187 @@
package com.huifu.adapay.demo;
import com.huifu.adapay.Adapay;
import com.huifu.adapay.model.MerConfig;
import java.util.HashMap;
import java.util.Map;
/**
* @author jane.zhao
*/
public class MainDemo {
public static void main(String[] args) throws Exception {
//若是商户只是自己对接adapay请使用如下demo
testMerchant();
//若是技术性渠道商为其它商户提供服务功能,请使用多商户模式
// testMultiMerchant();
}
public static void testMerchant() throws Exception {
/**
* debug 模式,开启后有详细的日志
*/
Adapay.debug = true;
/**
* prodMode 模式默认为生产模式false可以使用mock模式
*/
Adapay.prodMode = true;
/**
* 初始化商户配置,服务器启动前,必须通过该方式初始化商户配置完成
* apiKey为prod模式的API KEY
* mockApiKey为mock模式的API KEY
* rsaPrivateKey为商户发起请求时用于请求参数加签所需要的RSA私钥
*/
String apiKey = "api_live_9c14f264-e390-41df-984d-df15a6952031";
String mockApiKey = "api_test_e640fa26-bbe6-458f-ac44-a71723ee2176";
String rsaPrivateKey = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMQhsygJ2pp4nCiDAXiqnZm6AzKSVAh+C0BgGR6QaeXzt0TdSi9VR0OQ7Qqgm92NREB3ofobXvxxT+wImrDNk6R6lnHPMTuJ/bYpm+sx397rPboRAXpV3kalQmbZ3P7oxtEWOQch0zV5B1bgQnTvxcG3REAsdaUjGs9Xvg0iDS2tAgMBAAECgYAqGFmNdF/4234Yq9V7ApOE1Qmupv1mPTdI/9ckWjaAZkilfSFY+2KqO8bEiygo6xMFCyg2t/0xDVjr/gTFgbn4KRPmYucGG+FzTRLH0nVIqnliG5Ekla6a4gwh9syHfstbOpIvJR4DfldicZ5n7MmcrdEwSmMwXrdinFbIS/P1+QJBAOr6NpFtlxVSGzr6haH5FvBWkAsF7BM0CTAUx6UNHb+RCYYQJbk8g3DLp7/vyio5uiusgCc04gehNHX4laqIdl8CQQDVrckvnYy+NLz+K/RfXEJlqayb0WblrZ1upOdoFyUhu4xqK0BswOh61xjZeS+38R8bOpnYRbLf7eoqb7vGpZ9zAkEAobhdsA99yRW+WgQrzsNxry3Ua1HDHaBVpnrWwNjbHYpDxLn+TJPCXvI7XNU7DX63i/FoLhOucNPZGExjLYBH/wJATHNZQAgGiycjV20yicvgla8XasiJIDP119h4Uu21A1Su8G15J2/9vbWn1mddg1pp3rwgvxhw312oInbHoFMxsQJBAJlyDDu6x05MeZ2nMor8gIokxq2c3+cnm4GYWZgboNgq/BknbIbOMBMoe8dJFj+ji3YNTvi1MSTDdSDqJuN/qS0=";
MerConfig merConfig = new MerConfig();
merConfig.setApiKey(apiKey);
merConfig.setApiMockKey(mockApiKey);
merConfig.setRSAPrivateKey(rsaPrivateKey);
Adapay.initWithMerConfig(merConfig);
/**
* 初始化完成,可以开始交易
*/
String appId = "app_7d87c043-aae3-4357-9b2c-269349a980d6";
// 运行支付类接口
// String pamentId = PaymentDemo.executePaymentTest(appId);
// 带区域和超时参数的支付请求Demo
String pamentId = PaymentRegionAndRequestTimeOutDemo.executePaymentTest(appId);
// //运行退款类接口
// RefundDemo.executeRefundTest("002112020010618571810060213271697731584");
// /**用户类接口*/
Map<String, Object> member = MemberDemo.executeMemberTest(appId);
String memberId = (String) member.get("member_id");
// /** 结算户绑定*/
SettleAccountDemo.executeSettleAccountTest("app_7d87c043-aae3-4357-9b2c-269349a980d6", memberId);
/**企业开户*/
CorpMemberDemo.executeCorpMemberTest("app_7d87c043-aae3-4357-9b2c-269349a980d6");
/**
* 对账单下载
*/
// BillDemo.executeBillTest();
// /**
// * 获取云闪付用户号
// */
// AdapayToolsDemo.executeToolsTest(appId);
// /**
// * 余额查询
// */
// SettleAccountDemo.executeQueryBalance(appId, "member_id", "settleCount_id");
// /**
// *用户取现
// */
// SettleAccountDemo.executeDrawCash(appId, "member_id");
// /**
// * 钱包登录申请
// */
// AdapayToolsDemo.executeLoginTest(appId,"member_id");
//银行卡管理
//FastPayDemo.executeCardTest(appId);
}
public static void testMultiMerchant() throws Exception {
/**
* debug 模式,开启后与详细的日志
*/
Adapay.debug = true;
/**
* prodMode 模式默认为生产模式false可以使用mock模式
*/
Adapay.prodMode = true;
/**
* 初始化每个商户配置,服务器启动前,必须通过该方式初始化商户配置完成
* apiKey为prod模式的API KEY
* mockApiKey为mock模式的API KEY
* rsaPrivateKey为商户发起请求时用于请求参数加签所需要的RSA私钥
*/
// 创建商户A的商户配置对象
Map<String, MerConfig> configPathMap = new HashMap<>();
String apiKeyA = "api_live_9c14f264-e390-41df-984d-df15a6952031";
String mockApiKeyA = "api_test_e640fa26-bbe6-458f-ac44-a71723ee2176";
String rsaPrivateKeyA = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMQhsygJ2pp4nCiDAXiqnZm6AzKSVAh+C0BgGR6QaeXzt0TdSi9VR0OQ7Qqgm92NREB3ofobXvxxT+wImrDNk6R6lnHPMTuJ/bYpm+sx397rPboRAXpV3kalQmbZ3P7oxtEWOQch0zV5B1bgQnTvxcG3REAsdaUjGs9Xvg0iDS2tAgMBAAECgYAqGFmNdF/4234Yq9V7ApOE1Qmupv1mPTdI/9ckWjaAZkilfSFY+2KqO8bEiygo6xMFCyg2t/0xDVjr/gTFgbn4KRPmYucGG+FzTRLH0nVIqnliG5Ekla6a4gwh9syHfstbOpIvJR4DfldicZ5n7MmcrdEwSmMwXrdinFbIS/P1+QJBAOr6NpFtlxVSGzr6haH5FvBWkAsF7BM0CTAUx6UNHb+RCYYQJbk8g3DLp7/vyio5uiusgCc04gehNHX4laqIdl8CQQDVrckvnYy+NLz+K/RfXEJlqayb0WblrZ1upOdoFyUhu4xqK0BswOh61xjZeS+38R8bOpnYRbLf7eoqb7vGpZ9zAkEAobhdsA99yRW+WgQrzsNxry3Ua1HDHaBVpnrWwNjbHYpDxLn+TJPCXvI7XNU7DX63i/FoLhOucNPZGExjLYBH/wJATHNZQAgGiycjV20yicvgla8XasiJIDP119h4Uu21A1Su8G15J2/9vbWn1mddg1pp3rwgvxhw312oInbHoFMxsQJBAJlyDDu6x05MeZ2nMor8gIokxq2c3+cnm4GYWZgboNgq/BknbIbOMBMoe8dJFj+ji3YNTvi1MSTDdSDqJuN/qS0=";
MerConfig merConfigA = new MerConfig();
merConfigA.setApiKey(apiKeyA);
merConfigA.setApiMockKey(mockApiKeyA);
merConfigA.setRSAPrivateKey(rsaPrivateKeyA);
// 定义一个商户的A的唯一标识交易发起时用于定位是哪个商户发起交易
configPathMap.put("商户A的唯一标识", merConfigA);
// 创建商户B的商户配置对象
String apiKeyB = "api_live_9c14f264-e390-41df-984d-df15a6952031";
String mockApiKeyB = "api_test_e640fa26-bbe6-458f-ac44-a71723ee2176";
String rsaPrivateKeyB = "MIICdwIBADANBgkqhkiG9w0BAQEFAASCAmEwggJdAgEAAoGBAMQhsygJ2pp4nCiDAXiqnZm6AzKSVAh+C0BgGR6QaeXzt0TdSi9VR0OQ7Qqgm92NREB3ofobXvxxT+wImrDNk6R6lnHPMTuJ/bYpm+sx397rPboRAXpV3kalQmbZ3P7oxtEWOQch0zV5B1bgQnTvxcG3REAsdaUjGs9Xvg0iDS2tAgMBAAECgYAqGFmNdF/4234Yq9V7ApOE1Qmupv1mPTdI/9ckWjaAZkilfSFY+2KqO8bEiygo6xMFCyg2t/0xDVjr/gTFgbn4KRPmYucGG+FzTRLH0nVIqnliG5Ekla6a4gwh9syHfstbOpIvJR4DfldicZ5n7MmcrdEwSmMwXrdinFbIS/P1+QJBAOr6NpFtlxVSGzr6haH5FvBWkAsF7BM0CTAUx6UNHb+RCYYQJbk8g3DLp7/vyio5uiusgCc04gehNHX4laqIdl8CQQDVrckvnYy+NLz+K/RfXEJlqayb0WblrZ1upOdoFyUhu4xqK0BswOh61xjZeS+38R8bOpnYRbLf7eoqb7vGpZ9zAkEAobhdsA99yRW+WgQrzsNxry3Ua1HDHaBVpnrWwNjbHYpDxLn+TJPCXvI7XNU7DX63i/FoLhOucNPZGExjLYBH/wJATHNZQAgGiycjV20yicvgla8XasiJIDP119h4Uu21A1Su8G15J2/9vbWn1mddg1pp3rwgvxhw312oInbHoFMxsQJBAJlyDDu6x05MeZ2nMor8gIokxq2c3+cnm4GYWZgboNgq/BknbIbOMBMoe8dJFj+ji3YNTvi1MSTDdSDqJuN/qS0=";
MerConfig merConfigB = new MerConfig();
merConfigB.setApiKey(apiKeyB);
merConfigB.setApiMockKey(mockApiKeyB);
merConfigB.setRSAPrivateKey(rsaPrivateKeyB);
// 定义一个商户的B的唯一标识交易发起时用于定位是哪个商户发起交易
configPathMap.put("商户B的唯一标识", merConfigB);
// 将商户A和B的商户配置放入本地缓存
Adapay.initWithMerConfigs(configPathMap);
/**
* 商户配置初始化完成后,可以发起交易
*/
// 运行支付类接口其中app_id必须是商户A下的app_id
String pamentId = PaymentDemo.executePaymentTest("商户A的唯一标识", "app_7d87c043-aae3-4357-9b2c-269349a980d6");
// String pamentI2 = PaymentDemo.executePaymentTest("yidian", "app_67ba475b-26e0-4cfa-847c-0f115cae5029");
// //运行退款类接口
// RefundDemo.executeRefundTest("yifuyun", "002112019101420422510029799145265012736");
// RefundDemo.executeRefundTest("yifuyun", "002112019101420422610029799148904755200");
// /**
// * 分账使用配套接口 begin
// */
// /**用户类接口*/
// Map<String, Object> member = MemberDemo.executeMemberTest("yifuyun", "app_67ba475b-26e0-4cfa-847c-0f115cae5029");
// String memberId = (String) member.get("member_id");
// /** 结算户绑定*/
// SettleAccountDemo.executeSettleAccountTest("yidian", "app_67ba475b-26e0-4cfa-847c-0f115cae5029", memberId);
// /**企业开户*/
// CorpMemberDemo.executeCorpMemberTest("yidian", "app_67ba475b-26e0-4cfa-847c-0f115cae5029");
// /**
// * 分账使用配套接口 end
// */
// //对账单下载
// BillDemo.executeBillTest("yifuyun");
// String appId = "app_67ba475b-26e0-4cfa-847c-0f115cae5029";
// /**
// * 获取云闪付用户号
// */
// AdapayToolsDemo.executeToolsTest(appId, "yifuyun");
// /**
// * 余额查询
// */
// SettleAccountDemo.executeQueryBalance("yifuyun", appId, "member_id", "settleCount_id");
// /**
// *用户取现
// */
// SettleAccountDemo.executeDrawCash("yifuyun", appId, "member_id");
// /**
// * 钱包登录申请
// */
// AdapayToolsDemo.executeLoginTest(appId,"yifuyun");
}
}

View File

@@ -0,0 +1,244 @@
package com.huifu.adapay.demo;
import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.huifu.adapay.model.Member;
/**
* @author yingyong.wang
*/
public class MemberDemo extends BaseDemo{
/**
* 运行 member 类接口
* @throws Exception 异常
*/
public static Map<String, Object> executeMemberTest(String merchantKey, String app_id) throws Exception{
MemberDemo demo = new MemberDemo();
Map<String, Object> member = demo.executeCreateMember(merchantKey, app_id);
demo.executeQueryMember(merchantKey, (String)member.get("member_id"),app_id);
demo.executeUpdateMember(merchantKey, (String)member.get("member_id"),app_id);
demo.executeQueryMember(merchantKey, (String)member.get("member_id"),app_id);
demo.executeListMember(merchantKey, app_id);
return member;
}
/**
* 创建 member
* @return 创建的member 对象
* @throws Exception 异常
*/
public Map<String, Object> executeCreateMember(String merchantKey, String app_id) throws Exception {
System.out.println("=======execute CreateMember begin=======");
Map<String, Object> memberParams = new HashMap<String, Object>(2);
memberParams.put("member_id", "jsdk_member_"+System.currentTimeMillis());
memberParams.put("app_id",app_id);
memberParams.put("location", "上海市徐汇区宜山路");
memberParams.put("email", "123@163.com");
memberParams.put("gender", "MALE");
memberParams.put("tel_no", "13153333333");
memberParams.put("nickname", "nick_name");
System.out.println("创建用户,请求参数:" + JSON.toJSONString(memberParams));
Map<String, Object> member = Member.create(memberParams, merchantKey);
System.out.println("创建用户,返回参数:" + JSON.toJSONString(member));
System.out.println("=======execute CreateMember end=======");
return member;
}
/**
* 查询 member
* @param member_id 待查询的member_id
* @return 创建的member 对象
* @throws Exception 异常
*/
public Map<String, Object> executeQueryMember(String merchantKey, String member_id,String app_id) throws Exception {
System.out.println("=======execute queryMember begin=======");
Map<String, Object> memberParams = new HashMap<String, Object>(2);
memberParams.put("member_id", member_id);
memberParams.put("app_id", app_id);
System.out.println("查询用户,请求参数:" + JSON.toJSONString(memberParams));
Map<String, Object> member = Member.query(memberParams, merchantKey);
System.out.println("查询用户,返回参数:" + JSON.toJSONString(member));
System.out.println("=======execute queryMember end=======");
return member;
}
/**
* 更新 member
* @param member_id 待更新的member_id
* @return 更新的member 对象
* @throws Exception 异常
*/
public Map<String, Object> executeUpdateMember(String merchantKey, String member_id,String app_id) throws Exception {
System.out.println("=======execute update Member begin=======");
Map<String, Object> memberParams = new HashMap<String, Object>(2);
memberParams.put("member_id", member_id);
memberParams.put("app_id", app_id);
memberParams.put("location", "上海市徐汇区宜山路1");
memberParams.put("email", "1234@163.com");
memberParams.put("gender", "MALE");
memberParams.put("tel_no", "13153333333");
memberParams.put("nickname", "nick_name2");
System.out.println("更新用户,请求参数:"+JSON.toJSONString(memberParams));
Map<String, Object> member = Member.update(memberParams, merchantKey);
System.out.println("更新用户,返回参数:"+JSON.toJSONString(member));
System.out.println("=======execute update Member end=======");
return member;
}
/**
* 查询 member list
* @param app_id app_id
* @return 查询的member list
* @throws Exception 异常
*/
public Map<String, Object> executeListMember(String merchantKey, String app_id) throws Exception {
System.out.println("=======execute list Member begin=======");
Map<String, Object> memberParams = new HashMap<String, Object>(2);
memberParams.put("page_index", "1");
memberParams.put("app_id", app_id);
memberParams.put("page_size", "20");
memberParams.put("created_gte", String.valueOf(System.currentTimeMillis() - 5 * 60 * 1000));
memberParams.put("created_lte", String.valueOf(System.currentTimeMillis()));
System.out.println("查询用户列表,请求参数:"+JSON.toJSONString(memberParams));
Map<String, Object> member = Member.queryList(memberParams, merchantKey);
System.out.println("查询用户列表,返回参数:"+JSON.toJSONString(member));
System.out.println("=======execute list Member end=======");
return member;
}
/**
* 运行 member 类接口
* @throws Exception 异常
*/
public static Map<String, Object> executeMemberTest( String app_id) throws Exception{
MemberDemo demo = new MemberDemo();
Map<String, Object> member = demo.executeCreateMember( app_id);
demo.executeQueryMember( (String)member.get("member_id"),app_id);
demo.executeUpdateMember( (String)member.get("member_id"),app_id);
demo.executeQueryMember( (String)member.get("member_id"),app_id);
demo.executeListMember( app_id);
return member;
}
/**
* 创建 member
* @return 创建的member 对象
* @throws Exception 异常
*/
public Map<String, Object> executeCreateMember( String app_id) throws Exception {
System.out.println("=======execute CreateMember begin=======");
Map<String, Object> memberParams = new HashMap<String, Object>(2);
memberParams.put("member_id", "jsdk_member_"+System.currentTimeMillis());
memberParams.put("app_id",app_id);
memberParams.put("location", "上海市徐汇区宜山路");
memberParams.put("email", "123@163.com");
memberParams.put("gender", "MALE");
memberParams.put("tel_no", "13153333333");
memberParams.put("nickname", "nick_name");
System.out.println("创建用户,请求参数:" + JSON.toJSONString(memberParams));
Map<String, Object> member = Member.create(memberParams);
System.out.println("创建用户,返回参数:" + JSON.toJSONString(member));
System.out.println("=======execute CreateMember end=======");
return member;
}
/**
* 查询 member
* @param member_id 待查询的member_id
* @return 创建的member 对象
* @throws Exception 异常
*/
public Map<String, Object> executeQueryMember( String member_id,String app_id) throws Exception {
System.out.println("=======execute queryMember begin=======");
Map<String, Object> memberParams = new HashMap<String, Object>(2);
memberParams.put("member_id", member_id);
memberParams.put("app_id", app_id);
System.out.println("查询用户,请求参数:" + JSON.toJSONString(memberParams));
Map<String, Object> member = Member.query(memberParams);
System.out.println("查询用户,返回参数:" + JSON.toJSONString(member));
System.out.println("=======execute queryMember end=======");
return member;
}
/**
* 更新 member
* @param member_id 待更新的member_id
* @return 更新的member 对象
* @throws Exception 异常
*/
public Map<String, Object> executeUpdateMember( String member_id,String app_id) throws Exception {
System.out.println("=======execute update Member begin=======");
Map<String, Object> memberParams = new HashMap<String, Object>(2);
memberParams.put("member_id", member_id);
memberParams.put("app_id", app_id);
memberParams.put("location", "上海市徐汇区宜山路1");
memberParams.put("email", "1234@163.com");
memberParams.put("gender", "MALE");
memberParams.put("tel_no", "13153333333");
memberParams.put("nickname", "nick_name2");
System.out.println("更新用户,请求参数:"+JSON.toJSONString(memberParams));
Map<String, Object> member = Member.update(memberParams);
System.out.println("更新用户,返回参数:"+JSON.toJSONString(member));
System.out.println("=======execute update Member end=======");
return member;
}
/**
* 查询 member list
* @param app_id app_id
* @return 查询的member list
* @throws Exception 异常
*/
public Map<String, Object> executeListMember( String app_id) throws Exception {
System.out.println("=======execute list Member begin=======");
Map<String, Object> memberParams = new HashMap<String, Object>(2);
memberParams.put("page_index", "1");
memberParams.put("app_id", app_id);
memberParams.put("page_size", "20");
memberParams.put("created_gte", String.valueOf(System.currentTimeMillis() - 5 * 60 * 1000));
memberParams.put("created_lte", String.valueOf(System.currentTimeMillis()));
System.out.println("查询用户列表,请求参数:"+JSON.toJSONString(memberParams));
Map<String, Object> member = Member.queryList(memberParams);
System.out.println("查询用户列表,返回参数:"+JSON.toJSONString(member));
System.out.println("=======execute list Member end=======");
return member;
}
}

View File

@@ -0,0 +1,964 @@
package com.huifu.adapay.demo;
import com.alibaba.fastjson.JSON;
import com.huifu.adapay.core.exception.BaseAdaPayException;
import com.huifu.adapay.model.Checkout;
import com.huifu.adapay.model.Payment;
import com.huifu.adapay.model.PaymentConfirm;
import com.huifu.adapay.model.PaymentReverse;
import java.util.HashMap;
import java.util.Map;
/**
* @author jane.zhao
*/
public class PaymentDemo extends BaseDemo {
/**
* 运行支付类接口
*
* @return paymentId
* @throws Exception 异常
*/
public static String executePaymentTest(String merchantKey, String app_id) throws Exception {
PaymentDemo demo = new PaymentDemo();
//支付接口
Map<String, Object> payment = demo.executePayment(merchantKey, app_id);
payment = demo.executeDelayPayment(merchantKey, app_id);
// payment = demo.createReverse(merchantKey, "002112019102420545010033426145952493568",app_id);
// payment = demo.queryReverse(merchantKey,"002112019102420545010033426145952493568", app_id);
// payment = demo.queryReverseList(merchantKey,"002112019102420545010033426145952493568", app_id);
// payment = demo.createConfirm(merchantKey,"002112019102420545010033426145952493568", app_id);
// payment = demo.queryConfirm(merchantKey,"002112019102420545010033426145952493568", app_id);
// payment = demo.queryConfirmList(merchantKey, "002112019102420545010033426145952493568",app_id);
//payment = demo.executePagePayment(merchantKey, app_id);
payment = demo.executeCheckOutPayment(merchantKey, app_id);
System.out.println("钱包支付地址:" + payment.get("pay_url"));
payment = demo.queryList(merchantKey,app_id);
//支付查询接口
demo.queryPayment(merchantKey, (String) payment.get("id"));
// //关单接口
demo.closePayment(merchantKey, (String) payment.get("id"));
return (String) payment.get("id");
}
/**
* 运行支付类接口
*
* @return paymentId
* @throws Exception 异常
*/
public static String executePaymentTest(String app_id) throws Exception {
PaymentDemo demo = new PaymentDemo();
//支付接口
Map<String, Object> payment = demo.executePayment(app_id);
// payment = demo.executeDelayPayment( app_id);
// payment = demo.createReverse("002112019102420545010033426145952493568", app_id);
// payment = demo.queryReverse("002112019102420545010033426145952493568", app_id);
// payment = demo.queryReverseList("002112019102420545010033426145952493568", app_id);
// payment = demo.createConfirm("002112019102420545010033426145952493568", app_id);
// payment = demo.queryConfirm("002112019102420545010033426145952493568", app_id);
// payment = demo.queryConfirmList("002112019102420545010033426145952493568", app_id);
//
// payment = demo.executePagePayment(app_id);
// payment = demo.executeCheckOutPayment(app_id);
// payment = demo.queryCheckoutList("002112019102420545010033426145952493568",app_id);
//
// System.out.println("钱包支付地址:" + payment.get("pay_url"));
//
// //支付查询接口
// demo.queryPayment((String) payment.get("id"));
// // //关单接口
// demo.closePayment((String) payment.get("id"));
return (String) payment.get("id");
}
/**
* 执行一个支付交易
*
* @return 创建的支付对象
* @throws Exception 异常
*/
public Map<String, Object> executeDelayPayment(String merchantKey, String app_id) throws Exception {
System.out.println("=======execute payment begin=======");
//创建支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html
Map<String, Object> paymentParams = new HashMap<>(10);
paymentParams.put("app_id", app_id);
paymentParams.put("order_no", "jsdk_payment_" + System.currentTimeMillis());
paymentParams.put("pay_channel", "alipay");
paymentParams.put("pay_amt", "0.01");
paymentParams.put("goods_title", "your goods title");
paymentParams.put("goods_desc", "your goods desc");
paymentParams.put("div_members", "");
paymentParams.put("pay_mode", "delay");
//调用sdk方法创建支付得到支付对象
Map<String, Object> payment = new HashMap<>();
try {
payment = Payment.create(paymentParams, merchantKey);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
String error_code = (String) payment.get("error_code");
if (null != error_code) {
String error_msg = (String) payment.get("error_msg");
System.out.println("error_code:" + error_code + "............." + error_msg);
}
return payment;
}
/**
* 执行一个支付交易
*
* @return 创建的支付对象
* @throws Exception 异常
*/
public Map<String, Object> executePayment(String merchantKey, String app_id) throws Exception {
System.out.println("=======execute payment begin=======");
//创建支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html
Map<String, Object> paymentParams = new HashMap<>(10);
paymentParams.put("app_id", app_id);
paymentParams.put("order_no", "jsdk_payment_" + System.currentTimeMillis());
paymentParams.put("pay_channel", "alipay");
paymentParams.put("pay_amt", "0.01");
paymentParams.put("goods_title", "your goods title");
paymentParams.put("goods_desc", "your goods desc");
paymentParams.put("div_members", "");
Map<String, Object> deviceInfo = new HashMap<>(2);
deviceInfo.put("device_ip", "127.0.0.1");
deviceInfo.put("device_mac", "交易设备 MAC");
deviceInfo.put("device_type", "1");
deviceInfo.put("device_imei", "交易设备 IMEI");
deviceInfo.put("device_imsi", "交易设备 IMSI");
deviceInfo.put("device_iccId", "ICCID");
deviceInfo.put("device_wifi_mac", "WIFIMAC");
paymentParams.put("device_info", deviceInfo);
Map<String, Object> expendParams = new HashMap<>(2);
String openId = "";//微信授权获取
expendParams.put("open_id", openId);
expendParams.put("is_raw", "1");
expendParams.put("callback_url", "绝对路径");
expendParams.put("limit_pay", "1");
paymentParams.put("expend", expendParams);
//调用sdk方法创建支付得到支付对象
Map<String, Object> payment = new HashMap<>();
try {
payment = Payment.create(paymentParams, merchantKey);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
String error_code = (String) payment.get("error_code");
if (null != error_code) {
System.out.println("创建支付返回参数:" + JSON.toJSONString(payment));
String error_msg = (String) payment.get("error_msg");
System.out.println("error_code:" + error_code + "............." + error_msg);
}
return payment;
}
/**
* 关闭一个支付交易
*
* @param paymentId 要关闭的支付id
* @return 关闭的支付对象
* @throws Exception 异常
*/
public Map<String, Object> closePayment(String merchantKey, String paymentId) throws Exception {
System.out.println("=======close payment begin=======");
//关闭支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html
//调用sdk方法关闭支付得到支付对象
Map<String, Object> payment = new HashMap<>();
Map<String, Object> paymentParams = new HashMap<>(10);
paymentParams.put("payment_id", paymentId);
try {
paymentParams.put("payment_id", paymentId);
paymentParams.put("reason", "reason");
paymentParams.put("expend", "expend");
paymentParams.put("notify_url", "notify_url");
System.out.println("关单请求参数:" + JSON.toJSONString(paymentId));
payment = Payment.close(paymentParams, merchantKey);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
String error_code = (String) payment.get("error_code");
if (null != error_code) {
System.out.println("关单返回参数:" + JSON.toJSONString(payment));
String error_msg = (String) payment.get("error_msg");
System.out.println("error_code:" + error_code + "............." + error_msg);
}
return payment;
}
/**
* 查询一个支付交易
*
* @param paymentId 要查询的支付id
* @return 查询的支付对象
* @throws Exception 异常
*/
public Map<String, Object> queryPayment(String merchantKey, String paymentId) throws Exception {
System.out.println("=======query payment begin=======");
//查询支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html
//调用sdk方法查询支付交易得到支付对象
Map<String, Object> payment = new HashMap<>();
try {
System.out.println("支付查询请求参数:" + JSON.toJSONString(paymentId));
payment = Payment.query(paymentId, merchantKey);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
System.out.println("支付查询返回参数:" + JSON.toJSONString(payment));
String error_code = (String) payment.get("error_code");
if (null == error_code) {
String error_msg = (String) payment.get("error_msg");
System.out.println("error_code:" + error_code + "............." + error_msg);
}
System.out.println("=======query payment end=======");
return payment;
}
/**
* 创建撤销对象
*
* @param paymentId 要查询的支付id
* @return 查询的支付对象
* @throws Exception 异常
*/
public Map<String, Object> createReverse(String merchantKey, String paymentId, String app_id) throws Exception {
System.out.println("=======create Reverse begin=======");
Map<String, Object> reverse = new HashMap<>();
reverse.put("payment_id", paymentId);
reverse.put("app_id", app_id);
reverse.put("order_no", "jsdk_reverse_" + System.currentTimeMillis());
reverse.put("app_id", app_id);
reverse.put("notify_url", "");
reverse.put("reverse_amt", "0.01");
reverse.put("reason", "reason");
reverse.put("expand", "expend");
reverse.put("device_info", "device_info");
try {
System.out.println("创建撤销对象" + JSON.toJSONString(reverse));
reverse = PaymentReverse.create(reverse, merchantKey);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
System.out.println("创建撤销对象返回参数:" + JSON.toJSONString(reverse));
String error_code = (String) reverse.get("error_code");
if (null == error_code) {
String error_msg = (String) reverse.get("error_msg");
System.out.println("error_code:" + error_code + "............." + error_msg);
}
System.out.println("=======create Reverse end=======");
return reverse;
}
/**
* 查询撤销对象
*
* @param reverse_id 要查询的支付id
* @return 查询的支付对象
* @throws Exception 异常
*/
public Map<String, Object> queryReverse(String merchantKey, String reverse_id, String app_id) throws Exception {
System.out.println("=======query Reverse begin=======");
Map<String, Object> reverse = new HashMap<>();
reverse.put("reverse_id", reverse_id);
try {
System.out.println("查询撤销对象请求参数:" + JSON.toJSONString(reverse));
reverse = PaymentReverse.query(reverse, merchantKey);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
String error_code = (String) reverse.get("error_code");
if (null == error_code) {
String error_msg = (String) reverse.get("error_msg");
System.out.println("error_code:" + error_code + "............." + error_msg);
}
System.out.println("查询撤销对象返回参数:" + JSON.toJSONString(reverse));
System.out.println("=======query Reverse end=======");
return reverse;
}
/**
* 查询撤销对象列表
*
* @param
* @return 查询的支付对象
* @throws Exception 异常
*/
public Map<String, Object> queryReverseList(String merchantKey, String payment_id, String app_id) throws Exception {
System.out.println("=======query Reverse list begin=======");
Map<String, Object> reverse = new HashMap<>();
reverse.put("payment_id", payment_id);
reverse.put("app_id", app_id);
reverse.put("page_index", "1");
reverse.put("page_size", "20");
reverse.put("created_gte", "1571913923");
reverse.put("created_lte", "1571913924");
try {
System.out.println("查询撤销对象列表请求参数:" + JSON.toJSONString(reverse));
reverse = PaymentReverse.queryList(reverse, merchantKey);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
String error_code = (String) reverse.get("error_code");
if (null == error_code) {
String error_msg = (String) reverse.get("error_msg");
System.out.println("error_code:" + error_code + "............." + error_msg);
}
System.out.println("查询撤销对象列表返回参数:" + JSON.toJSONString(reverse));
System.out.println("=======query Reverse list end=======");
return reverse;
}
/**
* 创建确认对象
*
* @return 查询的支付对象
* @throws Exception 异常
*/
public Map<String, Object> createConfirm(String merchantKey, String paymentId, String app_id) throws Exception {
System.out.println("=======create confirm begin=======");
Map<String, Object> confirm = new HashMap<>();
confirm.put("payment_id", paymentId);
confirm.put("order_no", "jsdk_confirm_" + System.currentTimeMillis());
confirm.put("confirm_amt", "0.01");
confirm.put("description", "description");
confirm.put("div_members", "");
try {
System.out.println("创建确认对象" + JSON.toJSONString(confirm));
confirm = PaymentConfirm.create(confirm, merchantKey);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
String error_code = (String) confirm.get("error_code");
if (null == error_code) {
String error_msg = (String) confirm.get("error_msg");
System.out.println("error_code:" + error_code + "............." + error_msg);
}
System.out.println("创建确认对象返回参数:" + JSON.toJSONString(confirm));
System.out.println("=======create confirm end=======");
return confirm;
}
/**
* 查询撤销对象
*
* @return 查询的支付对象
* @throws Exception 异常
*/
public Map<String, Object> queryConfirm(String merchantKey, String payment_confirm_id, String app_id) throws Exception {
System.out.println("=======query confirm begin=======");
Map<String, Object> confirm = new HashMap<>();
confirm.put("payment_confirm_id", payment_confirm_id);
try {
System.out.println("查询确认对象请求参数:" + JSON.toJSONString(confirm));
confirm = PaymentConfirm.query(confirm, merchantKey);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
String error_code = (String) confirm.get("error_code");
if (null == error_code) {
String error_msg = (String) confirm.get("error_msg");
System.out.println("error_code:" + error_code + "............." + error_msg);
}
System.out.println("查询撤销对象返回参数:" + JSON.toJSONString(confirm));
System.out.println("=======query confirm end=======");
return confirm;
}
/**
* 查询确认对象列表
*
* @param
* @return 查询的支付对象
* @throws Exception 异常
*/
public Map<String, Object> queryConfirmList(String merchantKey, String payment_id, String app_id) throws Exception {
System.out.println("=======query confirm list begin=======");
Map<String, Object> confirm = new HashMap<>();
confirm.put("payment_id", payment_id);
confirm.put("app_id", app_id);
confirm.put("page_index", "1");
confirm.put("page_size", "20");
confirm.put("created_gte", "1571913867");
confirm.put("created_lte", "1571913923");
try {
System.out.println("查询撤销对象列表请求参数:" + JSON.toJSONString(confirm));
confirm = PaymentConfirm.queryList(confirm, merchantKey);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
String error_code = (String) confirm.get("error_code");
if (null == error_code) {
String error_msg = (String) confirm.get("error_msg");
System.out.println("error_code:" + error_code + "............." + error_msg);
}
System.out.println("查询撤销对象列表返回参数:" + JSON.toJSONString(confirm));
System.out.println("=======query Reverse list end=======");
return confirm;
}
/**
* 执行一个支付交易
*
* @return 创建的支付对象
* @throws Exception 异常
*/
public Map<String, Object> executeDelayPayment(String app_id) throws Exception {
System.out.println("=======execute payment begin=======");
//创建支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html
Map<String, Object> paymentParams = new HashMap<>(10);
paymentParams.put("app_id", app_id);
paymentParams.put("order_no", "jsdk_payment_" + System.currentTimeMillis());
paymentParams.put("pay_channel", "alipay");
paymentParams.put("pay_amt", "0.10");
paymentParams.put("goods_title", "your goods title");
paymentParams.put("goods_desc", "your goods desc");
paymentParams.put("div_members", "");
paymentParams.put("pay_mode", "delay");
//调用sdk方法创建支付得到支付对象
Map<String, Object> payment = new HashMap<>();
try {
System.out.println("支付交易,请求参数:" + JSON.toJSONString(paymentParams));
payment = Payment.create(paymentParams);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
System.out.println("支付交易,返回参数:" + JSON.toJSONString(payment));
String error_code = (String) payment.get("error_code");
if (null == error_code) {
String error_msg = (String) payment.get("error_msg");
System.out.println("error_code:" + error_code + "............." + error_msg);
}
System.out.println("=======execute payment end=======");
return payment;
}
/**
* 执行一个支付交易
*
* @return 创建的支付对象
* @throws Exception 异常
*/
public Map<String, Object> executePayment(String app_id) throws Exception {
System.out.println("=======execute payment begin=======");
//创建支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html
Map<String, Object> paymentParams = new HashMap<>(10);
paymentParams.put("adapay_connection_request_timeout", 500);
paymentParams.put("adapay_connect_timeout", 500);
paymentParams.put("adapay_socket_timeout", 500);
paymentParams.put("adapay_region", "beijing");
paymentParams.put("app_id", app_id);
paymentParams.put("order_no", "jsdk_payment_" + System.currentTimeMillis());
paymentParams.put("pay_channel", "alipay");
paymentParams.put("pay_amt", "0.01");
paymentParams.put("goods_title", "your goods title");
paymentParams.put("goods_desc", "your goods desc");
paymentParams.put("div_members", "");
//调用sdk方法创建支付得到支付对象
Map<String, Object> payment = new HashMap<>();
try {
System.out.println("支付交易,请求参数:" + JSON.toJSONString(paymentParams));
payment = Payment.create(paymentParams);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
System.out.println("支付交易,返回参数:" + JSON.toJSONString(payment));
System.out.println("=======execute payment end=======");
return payment;
}
/**
* 执行一个包支付交易
*
* @return 创建的支付对象
* @throws Exception 异常
*/
public Map<String, Object> executePagePayment(String app_id) throws Exception {
System.out.println("=======execute pagePayment begin=======");
//请参考 https://docs.adapay.tech/api/index.html
Map<String, Object> params = new HashMap<>();
params.put("order_no", System.currentTimeMillis());
params.put("pay_amt", "0.01");
params.put("currency", "cny");
params.put("goods_title", "goods");
params.put("goods_desc", "goodsdesc");
params.put("app_id", app_id);
// params.put("app_id", "app_f8b14a77-dc24-433b-864f-98a62209d6c4");
params.put("callback_url", "https://www.baidu.com/");
//调用sdk方法创建支付得到支付对象
Map<String, Object> payment = new HashMap<>();
try {
System.out.println("钱包支付交易,请求参数:" + JSON.toJSONString(params));
payment = Payment.createPage(params);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
System.out.println("钱包交易,返回参数:" + JSON.toJSONString(payment));
System.out.println("=======execute pagePayment end=======");
return payment;
}
/**
* 执行一个包支付交易
*
* @return 创建的支付对象
* @throws Exception 异常
*/
public Map<String, Object> executePagePayment(String merchantKey, String app_id) throws Exception {
System.out.println("=======execute pagePayment begin=======");
//请参考 https://docs.adapay.tech/api/index.html
Map<String, Object> params = new HashMap<>();
params.put("order_no", System.currentTimeMillis());
params.put("pay_amt", "0.01");
params.put("currency", "cny");
params.put("goods_title", "goods");
params.put("goods_desc", "goodsdesc");
params.put("app_id", "app_f8b14a77-dc24-433b-864f-98a62209d6c4");
params.put("callback_url", "https://www.baidu.com/");
//调用sdk方法创建支付得到支付对象
Map<String, Object> payment = new HashMap<>();
try {
System.out.println("钱包支付交易,请求参数:" + JSON.toJSONString(params));
payment = Payment.createPage(params, merchantKey);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
System.out.println("钱包交易,返回参数:" + JSON.toJSONString(payment));
System.out.println("=======execute pagePayment end=======");
return payment;
}
/**
* 执行一个收银台支付交易
*
* @return 创建的支付对象
* @throws Exception 异常
*/
public Map<String, Object> executeCheckOutPayment(String app_id) throws Exception {
System.out.println("=======execute quickPayment begin=======");
//请参考 https://docs.adapay.tech/api/index.html
Map<String, Object> params = new HashMap<>();
params.put("order_no", "jdskjdd_200000014");
params.put("member_id", "user_00013");
params.put("pay_amt", "0.01");
params.put("currency", "cny");
params.put("goods_title", "商品标题");
params.put("goods_desc", "商品描述");
params.put("app_id", "app_7d87c043-aae3-4357-9b2c-269349a980d6");
params.put("callback_url", "https://www.cnblogs.com/wanlibingfeng/p/7080581.html");
//调用sdk方法创建支付得到支付对象
Map<String, Object> payment = new HashMap<>();
try {
System.out.println("收银台支付交易,请求参数:" + JSON.toJSONString(params));
payment = Checkout.create(params);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
System.out.println("收银台交易,返回参数:" + JSON.toJSONString(payment));
System.out.println("=======execute quickPayment end=======");
return payment;
}
/**
* 执行一个收银台支付交易
*
* @return 创建的支付对象
* @throws Exception 异常
*/
public Map<String, Object> executeCheckOutPayment(String merchantKey, String app_id) throws Exception {
System.out.println("=======execute quickPayment begin=======");
//请参考 https://docs.adapay.tech/api/index.html
Map<String, Object> params = new HashMap<>();
params.put("order_no", "jdskjdd_200000013");
params.put("member_id", "user_00013");
params.put("pay_amt", "0.01");
params.put("currency", "cny");
params.put("goods_title", "商品标题");
params.put("goods_desc", "商品描述");
params.put("app_id", "app_7d87c043-aae3-4357-9b2c-269349a980d6");
params.put("callback_url", "https://www.cnblogs.com/wanlibingfeng/p/7080581.html");
//调用sdk方法创建支付得到支付对象
Map<String, Object> payment = new HashMap<>();
try {
System.out.println("收银台支付交易,请求参数:" + JSON.toJSONString(params));
payment = Checkout.create(params, merchantKey);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
System.out.println("收银台交易,返回参数:" + JSON.toJSONString(payment));
System.out.println("=======execute quickPayment end=======");
return payment;
}
/**
* 关闭一个支付交易
*
* @param paymentId 要关闭的支付id
* @return 关闭的支付对象
* @throws Exception 异常
*/
public Map<String, Object> closePayment(String paymentId) throws Exception {
System.out.println("=======close payment begin=======");
//关闭支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html
//调用sdk方法关闭支付得到支付对象
Map<String, Object> payment = new HashMap<>();
try {
Map<String, Object> paymentParams = new HashMap<>(10);
paymentParams.put("payment_id", paymentId);
paymentParams.put("reason", "reason");
paymentParams.put("expend", "expend");
paymentParams.put("notify_url", "notify_url");
System.out.println("关单请求参数:" + JSON.toJSONString(paymentId));
payment = Payment.close(paymentParams);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
System.out.println("关单返回参数:" + JSON.toJSONString(payment));
System.out.println("=======close payment end=======");
return payment;
}
/**
* 查询一个支付交易
*
* @param paymentId 要查询的支付id
* @return 查询的支付对象
* @throws Exception 异常
*/
public Map<String, Object> queryPayment(String paymentId) throws Exception {
System.out.println("=======query payment begin=======");
//查询支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html
//调用sdk方法查询支付交易得到支付对象
Map<String, Object> payment = new HashMap<>();
try {
System.out.println("支付查询请求参数:" + JSON.toJSONString(paymentId));
payment = Payment.query(paymentId);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
System.out.println("支付查询返回参数:" + JSON.toJSONString(payment));
System.out.println("=======query payment end=======");
return payment;
}
/**
* 创建撤销对象
*
* @param paymentId 要查询的支付id
* @return 查询的支付对象
* @throws Exception 异常
*/
public Map<String, Object> createReverse(String paymentId, String app_id) throws Exception {
System.out.println("=======create Reverse begin=======");
Map<String, Object> reverse = new HashMap<>();
reverse.put("payment_id", paymentId);
reverse.put("app_id", app_id);
reverse.put("order_no", "jsdk_reverse_" + System.currentTimeMillis());
reverse.put("app_id", app_id);
reverse.put("notify_url", app_id);
reverse.put("reverse_amt", "0.01");
reverse.put("reason", app_id);
reverse.put("expand", app_id);
reverse.put("device_info", app_id);
try {
System.out.println("创建撤销对象" + JSON.toJSONString(reverse));
reverse = PaymentReverse.create(reverse);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
System.out.println("创建撤销对象返回参数:" + JSON.toJSONString(reverse));
System.out.println("=======create Reverse end=======");
return reverse;
}
/**
* 查询撤销对象
*
* @param reverse_id 要查询的支付id
* @return 查询的支付对象
* @throws Exception 异常
*/
public Map<String, Object> queryReverse(String reverse_id, String app_id) throws Exception {
System.out.println("=======query Reverse begin=======");
Map<String, Object> reverse = new HashMap<>();
reverse.put("reverse_id", reverse_id);
try {
System.out.println("查询撤销对象请求参数:" + JSON.toJSONString(reverse));
reverse = PaymentReverse.query(reverse);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
System.out.println("查询撤销对象返回参数:" + JSON.toJSONString(reverse));
System.out.println("=======query Reverse end=======");
return reverse;
}
/**
* 查询撤销对象列表
*
* @param
* @return 查询的支付对象
* @throws Exception 异常
*/
public Map<String, Object> queryReverseList(String payment_id, String app_id) throws Exception {
System.out.println("=======query Reverse list begin=======");
Map<String, Object> reverse = new HashMap<>();
reverse.put("payment_id", payment_id);
reverse.put("app_id", app_id);
reverse.put("page_index", "1");
reverse.put("page_size", "20");
reverse.put("created_gte", "");
reverse.put("created_lte", "");
try {
System.out.println("查询撤销对象列表请求参数:" + JSON.toJSONString(reverse));
reverse = PaymentReverse.queryList(reverse);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
System.out.println("查询撤销对象列表返回参数:" + JSON.toJSONString(reverse));
System.out.println("=======query Reverse list end=======");
return reverse;
}
/**
* 创建确认对象
*
* @return 查询的支付对象
* @throws Exception 异常
*/
public Map<String, Object> createConfirm(String paymentId, String app_id) throws Exception {
System.out.println("=======create confirm begin=======");
Map<String, Object> confirm = new HashMap<>();
confirm.put("payment_id", paymentId);
confirm.put("order_no", "jsdk_confirm_" + System.currentTimeMillis());
confirm.put("confirm_amt", "0.01");
confirm.put("description", "description");
confirm.put("div_members", "");
try {
System.out.println("创建确认对象" + JSON.toJSONString(confirm));
confirm = PaymentConfirm.create(confirm);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
System.out.println("创建确认对象返回参数:" + JSON.toJSONString(confirm));
System.out.println("=======create confirm end=======");
return confirm;
}
/**
* 查询撤销对象
*
* @return 查询的支付对象
* @throws Exception 异常
*/
public Map<String, Object> queryConfirm(String payment_confirm_id, String app_id) throws Exception {
System.out.println("=======query confirm begin=======");
Map<String, Object> confirm = new HashMap<>();
confirm.put("payment_confirm_id", payment_confirm_id);
try {
System.out.println("查询确认对象请求参数:" + JSON.toJSONString(confirm));
confirm = PaymentConfirm.query(confirm);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
System.out.println("查询撤销对象返回参数:" + JSON.toJSONString(confirm));
System.out.println("=======query confirm end=======");
return confirm;
}
/**
* 查询确认对象列表
*
* @param
* @return 查询的支付对象
* @throws Exception 异常
*/
public Map<String, Object> queryConfirmList(String payment_id, String app_id) throws Exception {
System.out.println("=======query confirm list begin=======");
Map<String, Object> confirm = new HashMap<>();
confirm.put("payment_id", payment_id);
confirm.put("app_id", app_id);
confirm.put("page_index", "1");
confirm.put("page_size", "20");
confirm.put("created_gte", "");
confirm.put("created_lte", "");
try {
System.out.println("查询撤销对象列表请求参数:" + JSON.toJSONString(confirm));
confirm = PaymentConfirm.queryList(confirm);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
System.out.println("查询撤销对象列表返回参数:" + JSON.toJSONString(confirm));
System.out.println("=======query Reverse list end=======");
return confirm;
}
//add beg
/**
* 查询确认对象列表
*
* @param
* @return 查询的支付对象列表
* @throws Exception 异常
*/
public Map<String, Object> queryList(String payment_id, String app_id) throws Exception {
System.out.println("=======query list begin=======");
Map<String, Object> querylist = new HashMap<>();
querylist.put("payment_id", payment_id);
querylist.put("app_id", app_id);
querylist.put("page_index", "1");
querylist.put("page_size", "20");
querylist.put("created_gte", "");
querylist.put("created_lte", "");
try {
System.out.println("查询支付对象列表请求参数:" + JSON.toJSONString(querylist));
querylist = Payment.queryList(querylist);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
System.out.println("查询支付对象列表返回参数:" + JSON.toJSONString(querylist));
System.out.println("=======query list end=======");
return querylist;
}
/**
* 查询收银台对象列表
*
* @param
* @return 查询的收银台对象列表
* @throws Exception 异常
*/
public Map<String, Object> queryCheckoutList(String payment_id, String app_id) throws Exception {
System.out.println("=======query list begin=======");
Map<String, Object> checklist = new HashMap<>();
checklist.put("payment_id", payment_id);
checklist.put("app_id", app_id);
checklist.put("page_index", "1");
checklist.put("page_size", "20");
checklist.put("created_gte", "");
checklist.put("created_lte", "");
try {
System.out.println("查询收银台对象列表请求参数:" + JSON.toJSONString(checklist));
checklist = Checkout.queryList(checklist);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
System.out.println("查询收银台对象列表返回参数:" + JSON.toJSONString(checklist));
System.out.println("=======query check list end=======");
return checklist;
}
//add end
}

View File

@@ -0,0 +1,149 @@
package com.huifu.adapay.demo;
import com.alibaba.fastjson.JSON;
import com.huifu.adapay.core.exception.BaseAdaPayException;
import com.huifu.adapay.model.Payment;
import java.util.HashMap;
import java.util.Map;
/**
* @author chunying.jia
*/
public class PaymentRegionAndRequestTimeOutDemo extends BaseDemo {
public static String executePaymentTest(String app_id)throws Exception{
PaymentRegionAndRequestTimeOutDemo demo = new PaymentRegionAndRequestTimeOutDemo();
//支付接口
Map<String, Object> payment = demo.executePayment(app_id);
return (String) payment.get("id");
}
/**
* 执行一个支付交易
*
* @return 创建的支付对象
* @throws Exception 异常
*/
public Map<String, Object> executePayment(String app_id) throws Exception {
System.out.println("=======execute payment begin=======");
//创建支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html
Map<String, Object> paymentParams = new HashMap<>(10);
// 设置超时时间 单位毫秒 类型 int
// adapay_connection_request_timeout 类型 int, 单位:毫秒 ms
// 非必须, 默认 10000 指从连接池获取连接的 timeout
paymentParams.put("adapay_connection_request_timeout", 1500);
// adapay_connect_timeout 单位:毫秒 ms
// 非必须, 默认 30000 指客户端和服务器建立连接的timeout
paymentParams.put("adapay_connect_timeout", 1500);
// adapay_socket_timeout 单位:毫秒 ms
// 非必须, 默认 30000 指客户端从服务器读取数据的timeout超出后会抛出SocketTimeOutException
paymentParams.put("adapay_socket_timeout", 1500);
// 设置网络区域
// 非必须, 默认 shanghai, 如果要使用其他区域请提交工单备注服务器公网出口IP地址申请开通beijing
paymentParams.put("adapay_region", "beijing");
paymentParams.put("app_id", app_id);
paymentParams.put("order_no", "jsdk_payment_" + System.currentTimeMillis());
paymentParams.put("pay_channel", "alipay");
paymentParams.put("pay_amt", "0.01");
paymentParams.put("goods_title", "your goods title");
paymentParams.put("goods_desc", "your goods desc");
paymentParams.put("div_members", "");
//调用sdk方法创建支付得到支付对象
Map<String, Object> payment = new HashMap<>();
try {
System.out.println("支付交易,请求参数:" + JSON.toJSONString(paymentParams));
payment = Payment.create(paymentParams);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
System.out.println("支付交易,返回参数:" + JSON.toJSONString(payment));
System.out.println("=======execute payment end=======");
return payment;
}
/**
* 关闭一个支付交易
*
* @param paymentId 要关闭的支付id
* @return 关闭的支付对象
* @throws Exception 异常
*/
public Map<String, Object> closePayment(String paymentId) throws Exception {
System.out.println("=======close payment begin=======");
//关闭支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html
//调用sdk方法关闭支付得到支付对象
Map<String, Object> payment = new HashMap<>();
try {
Map<String, Object> paymentParams = new HashMap<>(10);
paymentParams.put("payment_id", paymentId);
// 设置超时时间 单位毫秒 类型 int
// adapay_connection_request_timeout 类型 int, 单位:毫秒 ms
// 非必须, 默认 10000 指从连接池获取连接的 timeout
paymentParams.put("adapay_connection_request_timeout", 1500);
// adapay_connect_timeout 单位:毫秒 ms
// 非必须, 默认 30000 指客户端和服务器建立连接的timeout
paymentParams.put("adapay_connect_timeout", 1500);
// adapay_socket_timeout 单位:毫秒 ms
// 非必须, 默认 30000 指客户端从服务器读取数据的timeout超出后会抛出SocketTimeOutException
paymentParams.put("adapay_socket_timeout", 1500);
// 设置网络区域
// 非必须, 默认 shanghai, 如果要使用其他区域请提交工单备注服务器公网出口IP地址申请开通beijing
paymentParams.put("adapay_region", "beijing");
paymentParams.put("reason", "reason");
paymentParams.put("expend", "expend");
paymentParams.put("notify_url", "notify_url");
System.out.println("关单请求参数:" + JSON.toJSONString(paymentId));
payment = Payment.close(paymentParams);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
System.out.println("关单返回参数:" + JSON.toJSONString(payment));
System.out.println("=======close payment end=======");
return payment;
}
/**
* 查询一个支付交易
*
* @param paymentId 要查询的支付id
* @return 查询的支付对象
* @throws Exception 异常
*/
public Map<String, Object> queryPayment(String paymentId) throws Exception {
System.out.println("=======query payment begin=======");
//查询支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html
//调用sdk方法查询支付交易得到支付对象
Map<String, Object> payment = new HashMap<>();
try {
System.out.println("支付查询请求参数:" + JSON.toJSONString(paymentId));
payment = Payment.query(paymentId);
} catch (BaseAdaPayException e) {
e.printStackTrace();
}
System.out.println("支付查询返回参数:" + JSON.toJSONString(payment));
System.out.println("=======query payment end=======");
return payment;
}
}

View File

@@ -0,0 +1,157 @@
package com.huifu.adapay.demo;
import java.util.HashMap;
import java.util.Map;
import com.alibaba.fastjson.JSON;
import com.huifu.adapay.model.Refund;
/**
* @author jane.zhao
*/
public class RefundDemo extends BaseDemo {
/**
* 运行退款类接口
*
* @throws Exception 异常
*/
public static void executeRefundTest(String merchantKey, String paymentId) throws Exception {
RefundDemo demo = new RefundDemo();
//退款接口
Map<String, Object> refund = demo.executeRefund(merchantKey, paymentId);
//退款查询接口通过pamentId查询
demo.queryByPaymentId(merchantKey, paymentId);
//退款查询接口通过refundId查询
demo.queryByRefundId(merchantKey, (String) refund.get("id"));
}
/**
* 执行一个退款交易
*
* @param paymentId 要退款的原支付paymentId
* @return 创建的退款对象
* @throws Exception 异常
*/
public Map<String, Object> executeRefund(String merchantKey, String paymentId) throws Exception {
System.out.println("=======execute refund begin=======");
Map<String, Object> refundParams = new HashMap<String, Object>(2);
refundParams.put("refund_amt", "0.01");
refundParams.put("app_id", "your appid");
refundParams.put("refund_order_no", "jsdk_refund_"+System.currentTimeMillis());
System.out.println("退款请求参数:" + JSON.toJSONString(refundParams));
Map<String, Object> refund = Refund.create(paymentId, refundParams, merchantKey);
System.out.println("退款返回参数:" + JSON.toJSONString(refund));
System.out.println("=======execute refund end=======");
return refund;
}
/**
* 根据原支付id查询一个退款交易
*
* @param paymentId 要查询退款的原支付paymentId
* @return 查询的退款对象可能含多个退款明细RefundDetail
* @throws Exception 异常
*/
public Map<String, Object> queryByPaymentId(String merchantKey, String paymentId) throws Exception {
System.out.println("=======query refund by paymentId begin=======");
Map<String, Object> refundParams = new HashMap<String, Object>(1);
refundParams.put("payment_id", paymentId);
System.out.println("通过原支付ID查询退款交易请求参数" + JSON.toJSONString(refundParams));
Map<String, Object> refund = Refund.query(refundParams, merchantKey);
System.out.println("通过原支付ID查询退款交易返回参数" + JSON.toJSONString(refund));
System.out.println("=======query refund by paymentId end=======");
return refund;
}
/**
* 根据退款refundId查询一个退款交易
*
* @param refundId 要查询的退款refundId
* @return 查询的退款对象
* @throws Exception 异常
*/
public Map<String, Object> queryByRefundId(String merchantKey, String refundId) throws Exception {
System.out.println("=======query refund by refundid begin=======");
Map<String, Object> refundParams = new HashMap<String, Object>(1);
refundParams.put("refund_id", refundId);
System.out.println("通过refundId查询退款交易请求参数" + JSON.toJSONString(refundParams));
Map<String, Object> refund = Refund.query(refundParams, merchantKey);
System.out.println("通过refundId查询退款交易返回参数" + JSON.toJSONString(refund));
System.out.println("=======query refund by refundid end=======");
return refund;
}
/**
* 运行退款类接口
*
* @throws Exception 异常
*/
public static void executeRefundTest( String paymentId) throws Exception {
RefundDemo demo = new RefundDemo();
//退款接口
Map<String, Object> refund = demo.executeRefund( paymentId);
//退款查询接口通过pamentId查询
demo.queryByPaymentId( paymentId);
//退款查询接口通过refundId查询
demo.queryByRefundId( (String) refund.get("id"));
}
/**
* 执行一个退款交易
*
* @param paymentId 要退款的原支付paymentId
* @return 创建的退款对象
* @throws Exception 异常
*/
public Map<String, Object> executeRefund( String paymentId) throws Exception {
System.out.println("=======execute refund begin=======");
Map<String, Object> refundParams = new HashMap<String, Object>(2);
refundParams.put("refund_amt", "0.01");
refundParams.put("app_id", "your appid");
refundParams.put("refund_order_no", "jsdk_refund_"+System.currentTimeMillis());
System.out.println("退款请求参数:" + JSON.toJSONString(refundParams));
Map<String, Object> refund = Refund.create(paymentId, refundParams);
System.out.println("退款返回参数:" + JSON.toJSONString(refund));
System.out.println("=======execute refund end=======");
return refund;
}
/**
* 根据原支付id查询一个退款交易
*
* @param paymentId 要查询退款的原支付paymentId
* @return 查询的退款对象可能含多个退款明细RefundDetail
* @throws Exception 异常
*/
public Map<String, Object> queryByPaymentId( String paymentId) throws Exception {
System.out.println("=======query refund by paymentId begin=======");
Map<String, Object> refundParams = new HashMap<String, Object>(1);
refundParams.put("payment_id", paymentId);
System.out.println("通过原支付ID查询退款交易请求参数" + JSON.toJSONString(refundParams));
Map<String, Object> refund = Refund.query(refundParams);
System.out.println("通过原支付ID查询退款交易返回参数" + JSON.toJSONString(refund));
System.out.println("=======query refund by paymentId end=======");
return refund;
}
/**
* 根据退款refundId查询一个退款交易
*
* @param refundId 要查询的退款refundId
* @return 查询的退款对象
* @throws Exception 异常
*/
public Map<String, Object> queryByRefundId( String refundId) throws Exception {
System.out.println("=======query refund by refundid begin=======");
Map<String, Object> refundParams = new HashMap<String, Object>(1);
refundParams.put("refund_id", refundId);
System.out.println("通过refundId查询退款交易请求参数" + JSON.toJSONString(refundParams));
Map<String, Object> refund = Refund.query(refundParams);
System.out.println("通过refundId查询退款交易返回参数" + JSON.toJSONString(refund));
System.out.println("=======query refund by refundid end=======");
return refund;
}
}

View File

@@ -0,0 +1,853 @@
package com.huifu.adapay.demo;
import com.alibaba.fastjson.JSON;
import com.huifu.adapay.model.Drawcash;
import com.huifu.adapay.model.SettleAccount;
import java.util.HashMap;
import java.util.Map;
/**
* @author yingyong.wang
*/
public class SettleAccountDemo extends BaseDemo {
/**
* 运行结算账户类接口
*
* @throws Exception 异常
*/
public static void executeSettleAccountTest(String merchantKey, String app_id, String member_id) throws Exception {
SettleAccountDemo demo = new SettleAccountDemo();
// 创建结算账户
Map<String, Object> settlecount = demo.executeCreateSettleAccount(merchantKey, app_id, member_id);
String settleCount_id = (String) settlecount.get("id");
// 查询结算账户
demo.executeQuerySettleAccount(merchantKey, settleCount_id, app_id, member_id);
// 查询结算账户明细列表
demo.executeQuerySettleDetails(merchantKey, app_id, member_id, settleCount_id);
// 删除结算账户
demo.executeDeleteSettleAccount(merchantKey, settleCount_id, app_id, member_id);
member_id = "user_test_10001";
settleCount_id = "0023056905335360";
demo.executeModifySettleAccount(merchantKey, settleCount_id, app_id, member_id);
// SettleAccountDemo.executeDrawCash(merchantKey, app_id, member_id);
//
// SettleAccountDemo.executeQueryBalance(merchantKey, app_id, member_id, settleCount_id);
demo.executeTransfer(app_id,member_id);
demo.executeTransferList(app_id,member_id,settleCount_id);
demo.executeCommission(app_id,member_id);
demo.executeCommissionList(app_id);
}
/**
* 运行查询结算明细列表接口
*
* @throws Exception 异常
*/
// public static void executeQuerySettleDetailTest(String merchantKey, String appId, String memberId, String settleAccountId, String beginDate, String endDate) throws Exception {
// SettleAccountDemo demo = new SettleAccountDemo();
// demo.executeQuerySettleDetails(merchantKey, appId, memberId, settleAccountId, beginDate, endDate);
// }
/**
* 创建 settleCount
*
* @return 创建的settleCount 对象
* @throws Exception 异常
*/
public Map<String, Object> executeCreateSettleAccount(String merchantKey, String app_id, String member_id) throws Exception {
System.out.println("=======execute Create SettleAccount begin=======");
Map<String, Object> settleCountParams = new HashMap<String, Object>(2);
Map<String, Object> accountInfo = new HashMap<String, Object>(2);
accountInfo.put("card_id", "6222021703001692221");
accountInfo.put("card_name", "袁电茜");
accountInfo.put("cert_id", "310109200006062491");
accountInfo.put("cert_type", "00");
accountInfo.put("tel_no", "18888888881");
accountInfo.put("bank_code", "03060000");
accountInfo.put("bank_acct_type", "1");
accountInfo.put("prov_code", "0031");
accountInfo.put("area_code", "3100");
settleCountParams.put("member_id", member_id);
settleCountParams.put("app_id", app_id);
settleCountParams.put("channel", "bank_account");
settleCountParams.put("account_info", accountInfo);
System.out.println("创建结算账户,请求参数:" + JSON.toJSONString(settleCountParams));
Map<String, Object> settleCount = SettleAccount.create(settleCountParams, merchantKey);
System.out.println("创建结算账户,返回参数:" + JSON.toJSONString(settleCount));
System.out.println("=======execute Create SettleAccount end=======");
return settleCount;
}
/**
* 查询 SettleAccount
*
* @param settleCount_id 待查询的settleCount_id
* @param app_id app_id
* @return 查询的settleCount 对象
* @throws Exception 异常
*/
public Map<String, Object> executeQuerySettleAccount(String merchantKey, String settleCount_id, String app_id, String member_id) throws Exception {
System.out.println("=======execute query SettleAccount begin=======");
Map<String, Object> settleCountParams = new HashMap<String, Object>(2);
settleCountParams.put("settle_account_id", settleCount_id);
settleCountParams.put("member_id", member_id);
settleCountParams.put("app_id", app_id);
System.out.println("查询结算账户,请求参数:" + JSON.toJSONString(settleCountParams));
Map<String, Object> settleCount = SettleAccount.query(settleCountParams, merchantKey);
System.out.println("查询结算账户,返回参数:" + JSON.toJSONString(settleCount));
System.out.println("=======execute query SettleAccount end=======");
return settleCount;
}
/**
* 删除 SettleAccount
*
* @param settleCount_id 待删除的settleCount_id
* @param app_id app_id
* @return delete的settleCount 对象
* @throws Exception 异常
*/
public Map<String, Object> executeDeleteSettleAccount(String merchantKey, String settleCount_id, String app_id, String member_id) throws Exception {
System.out.println("=======execute delete SettleAccount begin=======");
Map<String, Object> settleCountParams = new HashMap<String, Object>(2);
settleCountParams.put("settle_account_id", settleCount_id);
settleCountParams.put("member_id", member_id);
settleCountParams.put("app_id", app_id);
System.out.println("删除结算账户,请求参数:" + JSON.toJSONString(settleCountParams));
Map<String, Object> settleCount = SettleAccount.delete(settleCountParams, merchantKey);
System.out.println("删除结算账户,返回参数:" + JSON.toJSONString(settleCount));
System.out.println("=======execute delete SettleAccount end=======");
return settleCount;
}
/**
* 查询结算明细列表
*
* @param merchantKey
* @param app_id app_id
* @param member_id 待查询的member_id
* @param settleAccountId 待查询的settleAccountId
* @return
* @throws Exception 异常
*/
public Map<String, Object> executeQuerySettleDetails(String merchantKey, String app_id, String member_id,
String settleAccountId) throws Exception {
System.out.println("=======execute query settle details begin=======");
Map<String, Object> querySettleDetailParams = new HashMap<String, Object>(2);
querySettleDetailParams.put("app_id", app_id);
querySettleDetailParams.put("member_id", member_id);
querySettleDetailParams.put("settle_account_id", settleAccountId);
querySettleDetailParams.put("begin_date", "20191008");
querySettleDetailParams.put("end_date", "20191010");
System.out.println("查询结算明细列表,请求参数:" + JSON.toJSONString(querySettleDetailParams));
Map<String, Object> settleCount = SettleAccount.detail(querySettleDetailParams, merchantKey);
System.out.println("查询结算明细列表,返回参数:" + JSON.toJSONString(settleCount));
System.out.println("=======execute query settle details end=======");
return settleCount;
}
/**
* 运行结算账户类接口
*
* @throws Exception 异常
*/
public static void executeSettleAccountTest(String app_id, String member_id) throws Exception {
SettleAccountDemo demo = new SettleAccountDemo();
// 创建结算账户
Map<String, Object> settlecount = demo.executeCreateSettleAccount(app_id, member_id);
String settleCount_id = (String) settlecount.get("id");
// 查询结算账户
demo.executeQuerySettleAccount(settleCount_id, app_id, member_id);
// 查询结算账户明细列表
demo.executeQuerySettleDetails(app_id, member_id, settleCount_id);
demo.executeTransfer(app_id,member_id);
demo.executeTransferList(app_id,member_id,settleCount_id);
demo.executeFreeze(app_id,member_id);
demo.executeFreezeList(app_id,member_id,settleCount_id);
demo.executeUnFreeze(app_id,member_id);
demo.executeUnFreezeList(app_id,member_id,settleCount_id);
demo.executeCommission(app_id,member_id);
demo.executeCommissionList(app_id);
}
/**
* 运行查询结算明细列表接口
*
* @throws Exception 异常
*/
// public static void executeQuerySettleDetailTest( String appId, String memberId, String settleAccountId, String beginDate, String endDate) throws Exception {
// SettleAccountDemo demo = new SettleAccountDemo();
// demo.executeQuerySettleDetails( appId, memberId, settleAccountId, beginDate, endDate);
// }
/**
* 创建 settleCount
*
* @return 创建的settleCount 对象
* @throws Exception 异常
*/
public Map<String, Object> executeCreateSettleAccount(String app_id, String member_id) throws Exception {
System.out.println("=======execute Create SettleAccount begin=======");
Map<String, Object> settleCountParams = new HashMap<String, Object>(2);
Map<String, Object> accountInfo = new HashMap<String, Object>(2);
accountInfo.put("card_id", "6222021703001692221");
accountInfo.put("card_name", "袁电茜");
accountInfo.put("cert_id", "310109200006062491");
accountInfo.put("cert_type", "00");
accountInfo.put("tel_no", "18888888881");
accountInfo.put("bank_code", "03060000");
accountInfo.put("bank_acct_type", "1");
accountInfo.put("prov_code", "0031");
accountInfo.put("area_code", "3100");
settleCountParams.put("member_id", member_id);
settleCountParams.put("app_id", app_id);
settleCountParams.put("channel", "bank_account");
settleCountParams.put("account_info", accountInfo);
System.out.println("创建结算账户,请求参数:" + JSON.toJSONString(settleCountParams));
Map<String, Object> settleCount = SettleAccount.create(settleCountParams);
System.out.println("创建结算账户,返回参数:" + JSON.toJSONString(settleCount));
System.out.println("=======execute Create SettleAccount end=======");
return settleCount;
}
/**
* 查询 SettleAccount
*
* @param settleCount_id 待查询的settleCount_id
* @param app_id app_id
* @return 查询的settleCount 对象
* @throws Exception 异常
*/
public Map<String, Object> executeQuerySettleAccount(String settleCount_id, String app_id, String member_id) throws Exception {
System.out.println("=======execute query SettleAccount begin=======");
Map<String, Object> settleCountParams = new HashMap<String, Object>(2);
settleCountParams.put("settle_account_id", settleCount_id);
settleCountParams.put("member_id", member_id);
settleCountParams.put("app_id", app_id);
System.out.println("查询结算账户,请求参数:" + JSON.toJSONString(settleCountParams));
Map<String, Object> settleCount = SettleAccount.query(settleCountParams);
System.out.println("查询结算账户,返回参数:" + JSON.toJSONString(settleCount));
System.out.println("=======execute query SettleAccount end=======");
return settleCount;
}
/**
* 修改 SettleAccount
*
* @param settleCount_id 待修改的settleCount_id
* @param app_id app_id
* @return 修改的settleCount 对象
* @throws Exception 异常
*/
public Map<String, Object> executeModifySettleAccount(String settleCount_id, String app_id, String member_id) throws Exception {
System.out.println("=======execute modify SettleAccount begin=======");
Map<String, Object> settleCountParams = new HashMap<String, Object>(2);
settleCountParams.put("settle_account_id", settleCount_id);
settleCountParams.put("member_id", member_id);
settleCountParams.put("app_id", app_id);
settleCountParams.put("min_amt", "0.10");
settleCountParams.put("remained_amt", "0.10");
System.out.println("修改结算账户,请求参数:" + JSON.toJSONString(settleCountParams));
Map<String, Object> settleCount = SettleAccount.update(settleCountParams);
System.out.println("修改结算账户,返回参数:" + JSON.toJSONString(settleCount));
System.out.println("=======execute modify SettleAccount end=======");
return settleCount;
}
/**
* 修改 SettleAccount
*
* @param settleCount_id 待修改的settleCount_id
* @param app_id app_id
* @return 修改的settleCount 对象
* @throws Exception 异常
*/
public Map<String, Object> executeModifySettleAccount(String merchantKey, String settleCount_id, String app_id, String member_id) throws Exception {
System.out.println("=======execute modify SettleAccount begin=======");
Map<String, Object> settleCountParams = new HashMap<String, Object>(2);
settleCountParams.put("settle_account_id", settleCount_id);
settleCountParams.put("member_id", member_id);
settleCountParams.put("app_id", app_id);
settleCountParams.put("min_amt", "");
settleCountParams.put("remained_amt", "");
System.out.println("修改结算账户,请求参数:" + JSON.toJSONString(settleCountParams));
Map<String, Object> settleCount = SettleAccount.modify(settleCountParams, merchantKey);
System.out.println("修改结算账户,返回参数:" + JSON.toJSONString(settleCount));
System.out.println("=======execute modify SettleAccount end=======");
return settleCount;
}
/**
* 删除 SettleAccount
*
* @param settleCount_id 待删除的settleCount_id
* @param app_id app_id
* @return delete的settleCount 对象
* @throws Exception 异常
*/
public Map<String, Object> executeDeleteSettleAccount(String settleCount_id, String app_id, String member_id) throws Exception {
System.out.println("=======execute delete SettleAccount begin=======");
Map<String, Object> settleCountParams = new HashMap<String, Object>(2);
settleCountParams.put("settle_account_id", settleCount_id);
settleCountParams.put("member_id", member_id);
settleCountParams.put("app_id", app_id);
System.out.println("删除结算账户,请求参数:" + JSON.toJSONString(settleCountParams));
Map<String, Object> settleCount = SettleAccount.delete(settleCountParams);
System.out.println("删除结算账户,返回参数:" + JSON.toJSONString(settleCount));
System.out.println("=======execute delete SettleAccount end=======");
return settleCount;
}
/**
* 查询结算明细列表
*
* @param app_id app_id
* @param member_id 待查询的member_id
* @param settleAccountId 待查询的settleAccountId
* @return
* @throws Exception 异常
*/
public Map<String, Object> executeQuerySettleDetails(String app_id, String member_id,
String settleAccountId) throws Exception {
System.out.println("=======execute query settle details begin=======");
Map<String, Object> querySettleDetailParams = new HashMap<String, Object>(2);
querySettleDetailParams.put("app_id", app_id);
querySettleDetailParams.put("member_id", member_id);
querySettleDetailParams.put("settle_account_id", settleAccountId);
querySettleDetailParams.put("begin_date", "20191008");
querySettleDetailParams.put("end_date", "20191010");
System.out.println("查询结算明细列表,请求参数:" + JSON.toJSONString(querySettleDetailParams));
Map<String, Object> settleCount = SettleAccount.detail(querySettleDetailParams);
System.out.println("查询结算明细列表,返回参数:" + JSON.toJSONString(settleCount));
System.out.println("=======execute query settle details end=======");
return settleCount;
}
/**
* 取现
*
* @param merchantKey
* @param app_id
* @param member_id
* @return
* @throws Exception
*/
public static Map<String, Object> executeDrawCash(String merchantKey, String app_id, String member_id) throws Exception {
System.out.println("=======execute modify SettleAccount begin=======");
Map<String, Object> settleCountParams = new HashMap<String, Object>();
settleCountParams.put("order_no", "jsdk_payment_" + System.currentTimeMillis());
settleCountParams.put("cash_amt", "0.01");
settleCountParams.put("member_id", "user_00008");
settleCountParams.put("app_id", app_id);
// settleCountParams.put("settle_account_id", "0008919797515968");
settleCountParams.put("cash_type", "T1");
settleCountParams.put("notify_url", "");
System.out.println("取现接口,请求参数:" + JSON.toJSONString(settleCountParams));
Map<String, Object> settleCount = Drawcash.create(settleCountParams, merchantKey);
System.out.println("取现接口返回参数" + JSON.toJSONString(settleCount));
System.out.println("=======execute modify SettleAccount end=======");
return settleCount;
}
/**
* 查询余额
*
* @param merchantKey
* @param app_id
* @param member_id
* @param settleCount_id
* @return
* @throws Exception
*/
public static Map<String, Object> executeQueryBalance(String merchantKey, String app_id, String member_id, String settleCount_id) throws Exception {
System.out.println("=======execute modify SettleAccount begin=======");
Map<String, Object> settleCountParams = new HashMap<String, Object>();
settleCountParams.put("app_id", app_id);
settleCountParams.put("member_id", "user_00008");
settleCountParams.put("settle_account_id", "0035172521665088");
System.out.println("查询余额账户,请求参数:" + JSON.toJSONString(settleCountParams));
Map<String, Object> settleCount = SettleAccount.balance(settleCountParams, merchantKey);
System.out.println("查询余额账户,返回参数:" + JSON.toJSONString(settleCount));
System.out.println("=======execute modify SettleAccount end=======");
return settleCount;
}
/**
* 取现
*
* @param app_id
* @param member_id
* @return
* @throws Exception
*/
public static Map<String, Object> executeDrawCash(String app_id, String member_id) throws Exception {
System.out.println("=======execute modify SettleAccount begin=======");
Map<String, Object> settleCountParams = new HashMap<String, Object>();
settleCountParams.put("order_no", "jsdk_payment_" + System.currentTimeMillis());
settleCountParams.put("cash_amt", "0.01");
settleCountParams.put("member_id", "user_00008");
settleCountParams.put("app_id", app_id);
// settleCountParams.put("settle_account_id", "0008919797515968");
settleCountParams.put("cash_type", "T1");
settleCountParams.put("notify_url", "");
System.out.println("取现接口,请求参数:" + JSON.toJSONString(settleCountParams));
Map<String, Object> settleCount = Drawcash.create(settleCountParams);
System.out.println("取现接口返回参数" + JSON.toJSONString(settleCount));
System.out.println("=======execute modify SettleAccount end=======");
return settleCount;
}
/**
* 查询余额
*
* @param app_id
* @param member_id
* @param settleCount_id
* @return
* @throws Exception
*/
public static Map<String, Object> executeQueryBalance(String app_id, String member_id, String settleCount_id) throws Exception {
System.out.println("=======execute modify SettleAccount begin=======");
Map<String, Object> settleCountParams = new HashMap<String, Object>();
settleCountParams.put("app_id", app_id);
settleCountParams.put("member_id", "user_00008");
settleCountParams.put("settle_account_id", "0035172521665088");
System.out.println("查询余额账户,请求参数:" + JSON.toJSONString(settleCountParams));
Map<String, Object> settleCount = SettleAccount.balance(settleCountParams);
System.out.println("查询余额账户,返回参数:" + JSON.toJSONString(settleCount));
System.out.println("=======execute modify SettleAccount end=======");
return settleCount;
}
/**
* 创建转账对象
*
* @param app_id
* @param member_id
* @return
* @throws Exception
*/
public Map<String, Object> executeTransfer(String app_id, String member_id) throws Exception {
System.out.println("=======execute transfer SettleAccount begin=======");
Map<String, Object> transferParams = new HashMap<>();
transferParams.put("order_no", "order_no_123");
transferParams.put("trans_amt", "0.01");
transferParams.put("app_id", "app_XXXXXXXX");
transferParams.put("in_member_id", "0");
transferParams.put("out_member_id", "user_member_id_test");
System.out.println("创建转账对象,请求参数:" + JSON.toJSONString(transferParams));
Map<String, Object> result = SettleAccount.transfer(transferParams);
System.out.println("创建转账对象,返回参数:" + JSON.toJSONString(result));
System.out.println("=======execute transfer SettleAccount end=======");
return result;
}
/**
* 创建转账对象
*
* @param app_id
* @param member_id
* @return
* @throws Exception
*/
public Map<String, Object> executeTransfer(String merchantKey, String app_id, String member_id) throws Exception {
System.out.println("=======execute transfer SettleAccount begin=======");
Map<String, Object> transferParams = new HashMap<>();
transferParams.put("order_no", "order_no_124");
transferParams.put("trans_amt", "0.01");
transferParams.put("app_id", "app_XXXXXXXX");
transferParams.put("in_member_id", "0");
transferParams.put("out_member_id", "user_member_id_test");
System.out.println("创建转账对象,请求参数:" + JSON.toJSONString(transferParams));
Map<String, Object> result = SettleAccount.transfer(transferParams);
System.out.println("创建转账对象,返回参数:" + JSON.toJSONString(result));
System.out.println("=======execute transfer SettleAccount end=======");
return result;
}
/**
* 查询账户转账对象列表
*
* @param app_id
* @param member_id
* @param settleCount_id
* @return
* @throws Exception
*/
public Map<String, Object> executeTransferList(String app_id, String member_id, String settleCount_id) throws Exception {
System.out.println("=======execute query transferList begin=======");
Map<String, Object> transferListParams = new HashMap<String, Object>();
transferListParams.put("app_id", "app_XXXXXXXX");
transferListParams.put("status", "succeeded");
transferListParams.put("page_index", "1");
transferListParams.put("page_size", "10");
transferListParams.put("created_gte", "1571466657929");
transferListParams.put("created_lte", "1571898657929");
System.out.println("查询账户转账对象列表,请求参数:" + JSON.toJSONString(transferListParams));
Map<String, Object> result = SettleAccount.transferList(transferListParams);
System.out.println("查询账户转账对象列表,返回参数:" + JSON.toJSONString(result));
System.out.println("=======execute query transferList end=======");
return result;
}
/**
* 查询账户转账对象列表
*
* @param app_id
* @param member_id
* @param settleCount_id
* @return
* @throws Exception
*/
public Map<String, Object> executeTransferList(String merchantKey, String app_id, String member_id, String settleCount_id) throws Exception {
System.out.println("=======execute query transferList begin=======");
Map<String, Object> transferListParams = new HashMap<String, Object>();
transferListParams.put("app_id", "app_XXXXXXXX");
transferListParams.put("status", "succeeded");
transferListParams.put("page_index", "1");
transferListParams.put("page_size", "10");
transferListParams.put("created_gte", "1571466657928");
transferListParams.put("created_lte", "1571898657928");
System.out.println("查询账户转账对象列表,请求参数:" + JSON.toJSONString(transferListParams));
Map<String, Object> result = SettleAccount.transferList(transferListParams);
System.out.println("查询账户转账对象列表,返回参数:" + JSON.toJSONString(result));
System.out.println("=======execute query transferList end=======");
return result;
}
/**
* 创建冻结对象
*
* @param app_id
* @param member_id
* @return
* @throws Exception
*/
public Map<String, Object> executeFreeze(String app_id, String member_id) throws Exception {
System.out.println("=======execute freeze SettleAccount begin=======");
Map<String, Object> freezeParam = new HashMap<String, Object>(4);
freezeParam.put("order_no", "1579163031383");
freezeParam.put("app_id", "app_XXXXXXXX");
freezeParam.put("account_freeze_id", "002112020111717230410174704123849117696");
Map<String, Object> result = SettleAccount.freeze(freezeParam);
System.out.println("创建冻结对象,返回参数:" + JSON.toJSONString(result));
System.out.println("=======execute freeze SettleAccount end=======");
return result;
}
/**
* 创建冻结对象
*
* @param app_id
* @param member_id
* @return
* @throws Exception
*/
public Map<String, Object> executeFreeze(String merchantKey, String app_id, String member_id) throws Exception {
System.out.println("=======execute freeze SettleAccount begin=======");
Map<String, Object> freezeParam = new HashMap<String, Object>(4);
freezeParam.put("order_no", "1579163031384");
freezeParam.put("app_id", "app_XXXXXXXX");
freezeParam.put("account_freeze_id", "002112020111717230410174704123849117696");
Map<String, Object> result = SettleAccount.freeze(freezeParam);
System.out.println("创建冻结对象,返回参数:" + JSON.toJSONString(result));
System.out.println("=======execute freeze SettleAccount end=======");
return result;
}
/**
* 查询账户冻结对象列表
*
* @param app_id
* @param member_id
* @param settleCount_id
* @return
* @throws Exception
*/
public Map<String, Object> executeFreezeList(String app_id, String member_id, String settleCount_id) throws Exception {
System.out.println("=======execute query freezeList begin=======");
Map<String, Object> params = new HashMap<>();
System.out.println("查询账户冻结对象列表,请求参数:" + JSON.toJSONString(params));
params.put("app_id", "app_XXXXXXXX");
params.put("status", "succeeded");
params.put("page_index", "1");
params.put("page_size", "10");
params.put("created_gte", "1571466657929");
params.put("created_lte", "1571898657929");
Map<String, Object> result = SettleAccount.freezeList(params);
System.out.println("查询账户冻结对象列表,返回参数:" + JSON.toJSONString(result));
System.out.println("=======execute query freezeList end=======");
return result;
}
/**
* 查询账户冻结对象列表
*
* @param app_id
* @param member_id
* @param settleCount_id
* @return
* @throws Exception
*/
public Map<String, Object> executeFreezeList(String merchantKey, String app_id, String member_id, String settleCount_id) throws Exception {
System.out.println("=======execute query freezeList begin=======");
Map<String, Object> params = new HashMap<>();
System.out.println("查询账户冻结对象列表,请求参数:" + JSON.toJSONString(params));
params.put("app_id", "app_XXXXXXXX");
params.put("status", "succeeded");
params.put("page_index", "1");
params.put("page_size", "10");
params.put("created_gte", "1571466657928");
params.put("created_lte", "1571898657928");
Map<String, Object> result = SettleAccount.freezeList(params);
System.out.println("查询账户冻结对象列表,返回参数:" + JSON.toJSONString(result));
System.out.println("=======execute query freezeList end=======");
return result;
}
/**
* 创建解冻对象
*
* @param app_id
* @param member_id
* @return
* @throws Exception
*/
public Map<String, Object> executeUnFreeze(String app_id, String member_id) throws Exception {
System.out.println("=======execute unfreeze SettleAccount begin=======");
Map<String, Object> unfreezeParam = new HashMap<String, Object>(4);
unfreezeParam.put("order_no", "1579163031383");
unfreezeParam.put("app_id", "app_XXXXXXXX");
unfreezeParam.put("account_freeze_id", "002112020111717230410174704123849117696");
Map<String, Object> result = SettleAccount.unfreeze(unfreezeParam);
System.out.println("创建解冻对象,返回参数:" + JSON.toJSONString(result));
System.out.println("=======execute unfreeze SettleAccount end=======");
return result;
}
/**
* 创建解冻对象
*
* @param app_id
* @param member_id
* @return
* @throws Exception
*/
public Map<String, Object> executeUnFreeze(String merchantKey, String app_id, String member_id) throws Exception {
System.out.println("=======execute unfreeze SettleAccount begin=======");
Map<String, Object> unfreezeParam = new HashMap<String, Object>(4);
unfreezeParam.put("order_no", "1579163031384");
unfreezeParam.put("app_id", "app_XXXXXXXX");
unfreezeParam.put("account_freeze_id", "002112020111717230410174704123849117696");
Map<String, Object> result = SettleAccount.unfreeze(unfreezeParam);
System.out.println("创建解冻对象,返回参数:" + JSON.toJSONString(result));
System.out.println("=======execute unfreeze SettleAccount end=======");
return result;
}
/**
* 查询账户解冻对象列表
*
* @param app_id
* @param member_id
* @param settleCount_id
* @return
* @throws Exception
*/
public Map<String, Object> executeUnFreezeList(String app_id, String member_id, String settleCount_id) throws Exception {
System.out.println("=======execute query unfreezeList begin=======");
Map<String, Object> params = new HashMap<>();
System.out.println("查询账户解冻对象列表,请求参数:" + JSON.toJSONString(params));
params.put("app_id", "app_XXXXXXXX");
params.put("status", "succeeded");
params.put("page_index", "1");
params.put("page_size", "10");
params.put("created_gte", "1571466657928");
params.put("created_lte", "1571898657928");
Map<String, Object> result = SettleAccount.unfreezeList(params);
System.out.println("查询账户解冻对象列表,返回参数:" + JSON.toJSONString(result));
System.out.println("=======execute query unfreezeList end=======");
return result;
}
/**
* 查询账户解冻对象列表
*
* @param app_id
* @param member_id
* @param settleCount_id
* @return
* @throws Exception
*/
public Map<String, Object> executeUnFreezeList(String merchantKey, String app_id, String member_id, String settleCount_id) throws Exception {
System.out.println("=======execute query unfreezeList begin=======");
Map<String, Object> params = new HashMap<>();
System.out.println("查询账户解冻对象列表,请求参数:" + JSON.toJSONString(params));
params.put("app_id", "app_XXXXXXXX");
params.put("status", "succeeded");
params.put("page_index", "1");
params.put("page_size", "10");
params.put("created_gte", "1571466657929");
params.put("created_lte", "1571898657929");
Map<String, Object> result = SettleAccount.unfreezeList(params);
System.out.println("查询账户解冻对象列表,返回参数:" + JSON.toJSONString(result));
System.out.println("=======execute query unfreezeList end=======");
return result;
}
/**
* 创建服务商分账对象
*
* @param app_id
* @return
* @throws Exception
*/
public Map<String, Object> executeCommission(String app_id, String member_id) throws Exception {
System.out.println("=======execute commissions SettleAccount begin=======");
Map<String, Object> params = new HashMap<String, Object>(4);
params.put("order_no", "commissions_10414212480035000003");
params.put("payment_id", "002112021011909284110197415174743904256");
params.put("trans_amt", "0.01");
System.out.println("创建服务商分账对象,请求参数:" + JSON.toJSONString(params));
Map<String, Object> result = SettleAccount.commission(params);
System.out.println("创建服务商分账对象,返回参数:" + JSON.toJSONString(result));
System.out.println("=======execute commissions SettleAccount end=======");
return result;
}
/**
* 创建服务商分账对象
*
* @param app_id
* @return
* @throws Exception
*/
public Map<String, Object> executeCommission(String merchantKey, String app_id, String member_id) throws Exception {
System.out.println("=======execute commissions SettleAccount begin=======");
Map<String, Object> params = new HashMap<String, Object>(4);
params.put("order_no", "1579163031383");
params.put("payment_id", "002112020111717230410174704123849117696");
params.put("trans_amt", "0.01");
System.out.println("创建服务商分账对象,请求参数:" + JSON.toJSONString(params));
Map<String, Object> result = SettleAccount.commission(params,merchantKey);
System.out.println("创建服务商分账对象,返回参数:" + JSON.toJSONString(result));
System.out.println("=======execute commissions SettleAccount end=======");
return result;
}
/**
* 查询服务商分账对象列表
*
* @param app_id
* @return
* @throws Exception
*/
public Map<String, Object> executeCommissionList(String app_id) throws Exception {
System.out.println("=======execute query unfreezeList begin=======");
Map<String, Object> params = new HashMap<>();
params.put("app_id", app_id);
params.put("status", "succeeded");
params.put("page_index", "1");
params.put("page_size", "10");
params.put("created_gte", "1571466657929");
params.put("created_lte", "1571898657929");
System.out.println("查询服务商分账对象列表,请求参数:" + JSON.toJSONString(params));
Map<String, Object> result = SettleAccount.commissionList(params);
System.out.println("查询服务商分账对象列表,返回参数:" + JSON.toJSONString(result));
System.out.println("=======execute query unfreezeList end=======");
return result;
}
/**
* 查询服务商分账对象列表
*
* @param app_id
* @return
* @throws Exception
*/
public Map<String, Object> executeCommissionList(String merchantKey, String app_id) throws Exception {
System.out.println("=======execute query unfreezeList begin=======");
Map<String, Object> params = new HashMap<>();
params.put("app_id", app_id);
params.put("status", "succeeded");
params.put("page_index", "1");
params.put("page_size", "10");
params.put("created_gte", "1571466657929");
params.put("created_lte", "1571898657929");
System.out.println("查询服务商分账对象列表,请求参数:" + JSON.toJSONString(params));
Map<String, Object> result = SettleAccount.commissionList(params,merchantKey);
System.out.println("查询服务商分账对象列表,返回参数:" + JSON.toJSONString(result));
System.out.println("=======execute query unfreezeList end=======");
return result;
}
}