diff --git a/jsowell-pile/pom.xml b/jsowell-pile/pom.xml index 161983f02..7b3711aba 100644 --- a/jsowell-pile/pom.xml +++ b/jsowell-pile/pom.xml @@ -77,6 +77,16 @@ com.fasterxml.jackson.dataformat jackson-dataformat-avro + + + com.huifu.adapay.core + adapay-core-sdk + + + + com.huifu.adapay + adapay-java-sdk + diff --git a/jsowell-pile/src/main/java/com/jsowell/adapay/demo/AdapayToolsDemo.java b/jsowell-pile/src/main/java/com/jsowell/adapay/demo/AdapayToolsDemo.java new file mode 100644 index 000000000..74a07f63a --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/adapay/demo/AdapayToolsDemo.java @@ -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 unionParam = new HashMap(2); + unionParam.put("order_no", "20190912"); + unionParam.put("app_id", appId); + unionParam.put("user_auth_code", "20190912"); + unionParam.put("app_up_identifier", "20190912"); + Map 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 unionParam = new HashMap(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 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 queryParams = new HashMap(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 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 queryParams = new HashMap(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 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 executeBillDownLoad() throws Exception { + + + Map downloadParam = new HashMap(2); + downloadParam.put("bill_date", "20190912"); + + Map 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; + } + +} diff --git a/jsowell-pile/src/main/java/com/jsowell/adapay/demo/BaseDemo.java b/jsowell-pile/src/main/java/com/jsowell/adapay/demo/BaseDemo.java new file mode 100644 index 000000000..4c2128169 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/adapay/demo/BaseDemo.java @@ -0,0 +1,7 @@ +package com.huifu.adapay.demo; + +/** + * @author jane.zhao + */ +public class BaseDemo { +} diff --git a/jsowell-pile/src/main/java/com/jsowell/adapay/demo/BillDemo.java b/jsowell-pile/src/main/java/com/jsowell/adapay/demo/BillDemo.java new file mode 100644 index 000000000..38f8fd1b1 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/adapay/demo/BillDemo.java @@ -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 download = demo.executeBillDownLoad(merchantKey); + + } + + /** + * 运行账单下载接口 + * @throws Exception 异常 + */ + public static void executeBillTest() throws Exception{ + BillDemo demo = new BillDemo(); + + Map download = demo.executeBillDownLoad(); + + } + + /** + * 执行一个下载对账文件操作 + * @return 下载链接 + * @throws Exception 异常 + */ + public Map executeBillDownLoad(String merchantKey) throws Exception { + System.out.println("=======execute download begin======="); + + Map downloadParam = new HashMap(2); + downloadParam.put("bill_date", "20190912"); + Map 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 executeBillDownLoad() throws Exception { + + + Map downloadParam = new HashMap(2); + downloadParam.put("bill_date", "20190912"); + + Map 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; + } + +} diff --git a/jsowell-pile/src/main/java/com/jsowell/adapay/demo/CorpMemberDemo.java b/jsowell-pile/src/main/java/com/jsowell/adapay/demo/CorpMemberDemo.java new file mode 100644 index 000000000..db283d018 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/adapay/demo/CorpMemberDemo.java @@ -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 member = demo.executeCreateMember(merchantKey, app_id); + demo.executeQueryMember(merchantKey, (String) member.get("member_id"), app_id); + + } + + + /** + * 创建 CorpMember + * + * @return 创建的CorpMember 对象 + * @throws Exception 异常 + */ + public Map executeCreateMember(String merchantKey, String app_id) throws Exception { + System.out.println("=======execute Create CorpMember begin======="); + Map memberParams = new HashMap(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 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 executeQueryMember(String merchantKey, String member_id,String app_id) throws Exception { + System.out.println("=======execute query CorpMember begin======="); + Map memberParams = new HashMap(2); + memberParams.put("member_id", member_id); + memberParams.put("app_id", app_id); + System.out.println("查询企业用户,请求参数:"+JSON.toJSONString(memberParams)); + Map 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 member = demo.executeCreateMember( app_id); + demo.executeQueryMember( (String) member.get("member_id"), app_id); + + } + + + /** + * 创建 CorpMember + * + * @return 创建的CorpMember 对象 + * @throws Exception 异常 + */ + public Map executeCreateMember( String app_id) throws Exception { + System.out.println("=======execute Create CorpMember begin======="); + Map memberParams = new HashMap(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 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 executeQueryMember( String member_id,String app_id) throws Exception { + System.out.println("=======execute query CorpMember begin======="); + Map memberParams = new HashMap(2); + memberParams.put("member_id", member_id); + memberParams.put("app_id", app_id); + System.out.println("查询企业用户,请求参数1:"+JSON.toJSONString(memberParams)); + Map member = CorpMember.query(memberParams); + System.out.println("查询企业用户,返回参数:"+JSON.toJSONString(member)); + + System.out.println("=======execute query CorpMember end======="); + + return member; + } + + +} diff --git a/jsowell-pile/src/main/java/com/jsowell/adapay/demo/FastPayDemo.java b/jsowell-pile/src/main/java/com/jsowell/adapay/demo/FastPayDemo.java new file mode 100644 index 000000000..b8f590092 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/adapay/demo/FastPayDemo.java @@ -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 executeCardTest(String app_id) throws Exception{ + FastPayDemo fastPayDemo = new FastPayDemo(); + Map 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 executeCardApply(String app_id) throws Exception { + System.out.println("=======execute executeCardApply begin======="); + Map applyParam = new HashMap(); + 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 result = FastPay.cardApply(applyParam); + System.out.println("=======execute executeCardApply end======="); + return result; + + } + + + /** + * 创建快捷绑卡确认 + * @return 创建快捷绑卡确认 对象 + * @throws Exception 异常 + */ + public Map executeCardConfirm(String app_id) throws Exception { + System.out.println("=======execute executeCardConfirm begin======="); + Map confirmParam = new HashMap(); + confirmParam.put("apply_id", app_id); + confirmParam.put("sms_code", "123456"); + confirmParam.put("notify_url", "https://xxxx.com/xxxx"); + Map result = FastPay.cardConfirm(confirmParam); + System.out.println("创建用户,返回参数:" + JSON.toJSONString(result)); + System.out.println("=======execute executeCardConfirm end======="); + + return result; + + } + /** + * 查询快捷卡对象列表 + * @return 查询快捷卡对象列表 + * @throws Exception 异常 + */ + public Map executeCardList( String app_id) throws Exception { + System.out.println("=======execute executeCardList begin======="); + Map listParam = new HashMap(); + listParam.put("app_id", app_id); + listParam.put("member_id", "member_id_test"); + listParam.put("token_no", "10000067502"); + Map result = FastPay.cardList(listParam); + System.out.println("查询用户,返回参数:" + JSON.toJSONString(result)); + + System.out.println("=======execute executeCardList end======="); + + return result; + + } + /** + * 创建支付对象 + * @return 创建支付对象 + * @throws Exception 异常 + */ + public Map executeConfirm( String app_id) throws Exception { + System.out.println("=======execute executeConfirm begin======="); + Map confirmParams = new HashMap(); + confirmParams.put("payment_id", "002112020012010545810065165317376983040"); + confirmParams.put("sms_code", "123456"); + confirmParams.put("app_id", app_id); + Map result = FastPay.confirm(confirmParams); + System.out.println("=======execute executeConfirm end======="); + return result; + + } + + /** + * 创建快捷支付短信重发 + * @return 创建快捷支付短信重发 + * @throws Exception 异常 + */ + public Map executeSendSms( String app_id) throws Exception { + System.out.println("=======execute executeSendSms begin======="); + Map smsCodeParam = new HashMap(); + smsCodeParam.put("payment_id", "20190912"); + Map result = FastPay.smsCode(smsCodeParam); + System.out.println("=======execute executeSendSms end======="); + return result; + + } + +} diff --git a/jsowell-pile/src/main/java/com/jsowell/adapay/demo/MainDemo.java b/jsowell-pile/src/main/java/com/jsowell/adapay/demo/MainDemo.java new file mode 100644 index 000000000..8bc5c7556 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/adapay/demo/MainDemo.java @@ -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 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 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 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"); + + } + + +} \ No newline at end of file diff --git a/jsowell-pile/src/main/java/com/jsowell/adapay/demo/MemberDemo.java b/jsowell-pile/src/main/java/com/jsowell/adapay/demo/MemberDemo.java new file mode 100644 index 000000000..46f31fc3f --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/adapay/demo/MemberDemo.java @@ -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 executeMemberTest(String merchantKey, String app_id) throws Exception{ + MemberDemo demo = new MemberDemo(); + Map 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 executeCreateMember(String merchantKey, String app_id) throws Exception { + System.out.println("=======execute CreateMember begin======="); + Map memberParams = new HashMap(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 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 executeQueryMember(String merchantKey, String member_id,String app_id) throws Exception { + System.out.println("=======execute queryMember begin======="); + Map memberParams = new HashMap(2); + memberParams.put("member_id", member_id); + memberParams.put("app_id", app_id); + System.out.println("查询用户,请求参数:" + JSON.toJSONString(memberParams)); + Map 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 executeUpdateMember(String merchantKey, String member_id,String app_id) throws Exception { + System.out.println("=======execute update Member begin======="); + Map memberParams = new HashMap(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 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 executeListMember(String merchantKey, String app_id) throws Exception { + System.out.println("=======execute list Member begin======="); + Map memberParams = new HashMap(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 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 executeMemberTest( String app_id) throws Exception{ + MemberDemo demo = new MemberDemo(); + Map 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 executeCreateMember( String app_id) throws Exception { + System.out.println("=======execute CreateMember begin======="); + Map memberParams = new HashMap(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 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 executeQueryMember( String member_id,String app_id) throws Exception { + System.out.println("=======execute queryMember begin======="); + Map memberParams = new HashMap(2); + memberParams.put("member_id", member_id); + memberParams.put("app_id", app_id); + System.out.println("查询用户,请求参数:" + JSON.toJSONString(memberParams)); + Map 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 executeUpdateMember( String member_id,String app_id) throws Exception { + System.out.println("=======execute update Member begin======="); + Map memberParams = new HashMap(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 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 executeListMember( String app_id) throws Exception { + System.out.println("=======execute list Member begin======="); + Map memberParams = new HashMap(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 member = Member.queryList(memberParams); + System.out.println("查询用户列表,返回参数:"+JSON.toJSONString(member)); + + + System.out.println("=======execute list Member end======="); + + return member; + + } + + +} diff --git a/jsowell-pile/src/main/java/com/jsowell/adapay/demo/PaymentDemo.java b/jsowell-pile/src/main/java/com/jsowell/adapay/demo/PaymentDemo.java new file mode 100644 index 000000000..299422a62 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/adapay/demo/PaymentDemo.java @@ -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 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 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 executeDelayPayment(String merchantKey, String app_id) throws Exception { + System.out.println("=======execute payment begin======="); + //创建支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html + Map 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 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 executePayment(String merchantKey, String app_id) throws Exception { + System.out.println("=======execute payment begin======="); + //创建支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html + Map 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 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 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 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 closePayment(String merchantKey, String paymentId) throws Exception { + System.out.println("=======close payment begin======="); + //关闭支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html + //调用sdk方法,关闭支付,得到支付对象 + Map payment = new HashMap<>(); + Map 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 queryPayment(String merchantKey, String paymentId) throws Exception { + System.out.println("=======query payment begin======="); + //查询支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html + //调用sdk方法,查询支付交易,得到支付对象 + Map 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 createReverse(String merchantKey, String paymentId, String app_id) throws Exception { + System.out.println("=======create Reverse begin======="); + + Map 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 queryReverse(String merchantKey, String reverse_id, String app_id) throws Exception { + System.out.println("=======query Reverse begin======="); + + Map 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 queryReverseList(String merchantKey, String payment_id, String app_id) throws Exception { + System.out.println("=======query Reverse list begin======="); + + Map 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 createConfirm(String merchantKey, String paymentId, String app_id) throws Exception { + System.out.println("=======create confirm begin======="); + + Map 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 queryConfirm(String merchantKey, String payment_confirm_id, String app_id) throws Exception { + System.out.println("=======query confirm begin======="); + + Map 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 queryConfirmList(String merchantKey, String payment_id, String app_id) throws Exception { + System.out.println("=======query confirm list begin======="); + + Map 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 executeDelayPayment(String app_id) throws Exception { + System.out.println("=======execute payment begin======="); + //创建支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html + Map 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 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 executePayment(String app_id) throws Exception { + System.out.println("=======execute payment begin======="); + //创建支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html + Map 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 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 executePagePayment(String app_id) throws Exception { + System.out.println("=======execute pagePayment begin======="); + //请参考 https://docs.adapay.tech/api/index.html + Map 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 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 executePagePayment(String merchantKey, String app_id) throws Exception { + System.out.println("=======execute pagePayment begin======="); + //请参考 https://docs.adapay.tech/api/index.html + Map 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 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 executeCheckOutPayment(String app_id) throws Exception { + System.out.println("=======execute quickPayment begin======="); + //请参考 https://docs.adapay.tech/api/index.html + Map 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 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 executeCheckOutPayment(String merchantKey, String app_id) throws Exception { + System.out.println("=======execute quickPayment begin======="); + //请参考 https://docs.adapay.tech/api/index.html + Map 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 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 closePayment(String paymentId) throws Exception { + System.out.println("=======close payment begin======="); + //关闭支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html + //调用sdk方法,关闭支付,得到支付对象 + Map payment = new HashMap<>(); + try { + Map 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 queryPayment(String paymentId) throws Exception { + System.out.println("=======query payment begin======="); + //查询支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html + //调用sdk方法,查询支付交易,得到支付对象 + Map 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 createReverse(String paymentId, String app_id) throws Exception { + System.out.println("=======create Reverse begin======="); + + Map 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 queryReverse(String reverse_id, String app_id) throws Exception { + System.out.println("=======query Reverse begin======="); + + Map 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 queryReverseList(String payment_id, String app_id) throws Exception { + System.out.println("=======query Reverse list begin======="); + + Map 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 createConfirm(String paymentId, String app_id) throws Exception { + System.out.println("=======create confirm begin======="); + + Map 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 queryConfirm(String payment_confirm_id, String app_id) throws Exception { + System.out.println("=======query confirm begin======="); + + Map 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 queryConfirmList(String payment_id, String app_id) throws Exception { + System.out.println("=======query confirm list begin======="); + + Map 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 queryList(String payment_id, String app_id) throws Exception { + System.out.println("=======query list begin======="); + + Map 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 queryCheckoutList(String payment_id, String app_id) throws Exception { + System.out.println("=======query list begin======="); + + Map 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 +} diff --git a/jsowell-pile/src/main/java/com/jsowell/adapay/demo/PaymentRegionAndRequestTimeOutDemo.java b/jsowell-pile/src/main/java/com/jsowell/adapay/demo/PaymentRegionAndRequestTimeOutDemo.java new file mode 100644 index 000000000..1ccb759d7 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/adapay/demo/PaymentRegionAndRequestTimeOutDemo.java @@ -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 payment = demo.executePayment(app_id); + + return (String) payment.get("id"); + } + + /** + * 执行一个支付交易 + * + * @return 创建的支付对象 + * @throws Exception 异常 + */ + public Map executePayment(String app_id) throws Exception { + System.out.println("=======execute payment begin======="); + //创建支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html + Map 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 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 closePayment(String paymentId) throws Exception { + System.out.println("=======close payment begin======="); + //关闭支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html + //调用sdk方法,关闭支付,得到支付对象 + Map payment = new HashMap<>(); + try { + Map 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 queryPayment(String paymentId) throws Exception { + System.out.println("=======query payment begin======="); + //查询支付对象的参数,全部参数请参考 https://docs.adapay.tech/api/index.html + //调用sdk方法,查询支付交易,得到支付对象 + Map 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; + } + +} diff --git a/jsowell-pile/src/main/java/com/jsowell/adapay/demo/RefundDemo.java b/jsowell-pile/src/main/java/com/jsowell/adapay/demo/RefundDemo.java new file mode 100644 index 000000000..05b4c5cf0 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/adapay/demo/RefundDemo.java @@ -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 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 executeRefund(String merchantKey, String paymentId) throws Exception { + System.out.println("=======execute refund begin======="); + Map refundParams = new HashMap(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 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 queryByPaymentId(String merchantKey, String paymentId) throws Exception { + System.out.println("=======query refund by paymentId begin======="); + Map refundParams = new HashMap(1); + refundParams.put("payment_id", paymentId); + System.out.println("通过原支付ID查询退款交易,请求参数:" + JSON.toJSONString(refundParams)); + Map 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 queryByRefundId(String merchantKey, String refundId) throws Exception { + System.out.println("=======query refund by refundid begin======="); + Map refundParams = new HashMap(1); + refundParams.put("refund_id", refundId); + System.out.println("通过refundId查询退款交易,请求参数:" + JSON.toJSONString(refundParams)); + Map 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 refund = demo.executeRefund( paymentId); + //退款查询接口(通过pamentId查询) + demo.queryByPaymentId( paymentId); + //退款查询接口(通过refundId查询) + demo.queryByRefundId( (String) refund.get("id")); + } + + /** + * 执行一个退款交易 + * + * @param paymentId 要退款的原支付paymentId + * @return 创建的退款对象 + * @throws Exception 异常 + */ + public Map executeRefund( String paymentId) throws Exception { + System.out.println("=======execute refund begin======="); + Map refundParams = new HashMap(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 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 queryByPaymentId( String paymentId) throws Exception { + System.out.println("=======query refund by paymentId begin======="); + Map refundParams = new HashMap(1); + refundParams.put("payment_id", paymentId); + System.out.println("通过原支付ID查询退款交易,请求参数:" + JSON.toJSONString(refundParams)); + Map 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 queryByRefundId( String refundId) throws Exception { + System.out.println("=======query refund by refundid begin======="); + Map refundParams = new HashMap(1); + refundParams.put("refund_id", refundId); + System.out.println("通过refundId查询退款交易,请求参数:" + JSON.toJSONString(refundParams)); + Map refund = Refund.query(refundParams); + System.out.println("通过refundId查询退款交易,返回参数:" + JSON.toJSONString(refund)); + System.out.println("=======query refund by refundid end======="); + return refund; + } +} diff --git a/jsowell-pile/src/main/java/com/jsowell/adapay/demo/SettleAccountDemo.java b/jsowell-pile/src/main/java/com/jsowell/adapay/demo/SettleAccountDemo.java new file mode 100644 index 000000000..373896cd9 --- /dev/null +++ b/jsowell-pile/src/main/java/com/jsowell/adapay/demo/SettleAccountDemo.java @@ -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 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 executeCreateSettleAccount(String merchantKey, String app_id, String member_id) throws Exception { + System.out.println("=======execute Create SettleAccount begin======="); + Map settleCountParams = new HashMap(2); + Map accountInfo = new HashMap(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 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 executeQuerySettleAccount(String merchantKey, String settleCount_id, String app_id, String member_id) throws Exception { + System.out.println("=======execute query SettleAccount begin======="); + Map settleCountParams = new HashMap(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 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 executeDeleteSettleAccount(String merchantKey, String settleCount_id, String app_id, String member_id) throws Exception { + System.out.println("=======execute delete SettleAccount begin======="); + Map settleCountParams = new HashMap(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 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 executeQuerySettleDetails(String merchantKey, String app_id, String member_id, + String settleAccountId) throws Exception { + System.out.println("=======execute query settle details begin======="); + Map querySettleDetailParams = new HashMap(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 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 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 executeCreateSettleAccount(String app_id, String member_id) throws Exception { + System.out.println("=======execute Create SettleAccount begin======="); + Map settleCountParams = new HashMap(2); + Map accountInfo = new HashMap(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 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 executeQuerySettleAccount(String settleCount_id, String app_id, String member_id) throws Exception { + System.out.println("=======execute query SettleAccount begin======="); + Map settleCountParams = new HashMap(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 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 executeModifySettleAccount(String settleCount_id, String app_id, String member_id) throws Exception { + System.out.println("=======execute modify SettleAccount begin======="); + Map settleCountParams = new HashMap(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 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 executeModifySettleAccount(String merchantKey, String settleCount_id, String app_id, String member_id) throws Exception { + System.out.println("=======execute modify SettleAccount begin======="); + Map settleCountParams = new HashMap(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 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 executeDeleteSettleAccount(String settleCount_id, String app_id, String member_id) throws Exception { + System.out.println("=======execute delete SettleAccount begin======="); + Map settleCountParams = new HashMap(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 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 executeQuerySettleDetails(String app_id, String member_id, + String settleAccountId) throws Exception { + System.out.println("=======execute query settle details begin======="); + Map querySettleDetailParams = new HashMap(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 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 executeDrawCash(String merchantKey, String app_id, String member_id) throws Exception { + System.out.println("=======execute modify SettleAccount begin======="); + Map settleCountParams = new HashMap(); + + 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 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 executeQueryBalance(String merchantKey, String app_id, String member_id, String settleCount_id) throws Exception { + System.out.println("=======execute modify SettleAccount begin======="); + Map settleCountParams = new HashMap(); + + 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 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 executeDrawCash(String app_id, String member_id) throws Exception { + System.out.println("=======execute modify SettleAccount begin======="); + Map settleCountParams = new HashMap(); + + 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 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 executeQueryBalance(String app_id, String member_id, String settleCount_id) throws Exception { + System.out.println("=======execute modify SettleAccount begin======="); + Map settleCountParams = new HashMap(); + + 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 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 executeTransfer(String app_id, String member_id) throws Exception { + System.out.println("=======execute transfer SettleAccount begin======="); + Map 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 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 executeTransfer(String merchantKey, String app_id, String member_id) throws Exception { + System.out.println("=======execute transfer SettleAccount begin======="); + Map 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 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 executeTransferList(String app_id, String member_id, String settleCount_id) throws Exception { + System.out.println("=======execute query transferList begin======="); + Map transferListParams = new HashMap(); + + 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 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 executeTransferList(String merchantKey, String app_id, String member_id, String settleCount_id) throws Exception { + System.out.println("=======execute query transferList begin======="); + Map transferListParams = new HashMap(); + + 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 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 executeFreeze(String app_id, String member_id) throws Exception { + System.out.println("=======execute freeze SettleAccount begin======="); + Map freezeParam = new HashMap(4); + freezeParam.put("order_no", "1579163031383"); + freezeParam.put("app_id", "app_XXXXXXXX"); + freezeParam.put("account_freeze_id", "002112020111717230410174704123849117696"); + Map 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 executeFreeze(String merchantKey, String app_id, String member_id) throws Exception { + System.out.println("=======execute freeze SettleAccount begin======="); + Map freezeParam = new HashMap(4); + freezeParam.put("order_no", "1579163031384"); + freezeParam.put("app_id", "app_XXXXXXXX"); + freezeParam.put("account_freeze_id", "002112020111717230410174704123849117696"); + Map 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 executeFreezeList(String app_id, String member_id, String settleCount_id) throws Exception { + System.out.println("=======execute query freezeList begin======="); + Map 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 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 executeFreezeList(String merchantKey, String app_id, String member_id, String settleCount_id) throws Exception { + System.out.println("=======execute query freezeList begin======="); + Map 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 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 executeUnFreeze(String app_id, String member_id) throws Exception { + System.out.println("=======execute unfreeze SettleAccount begin======="); + Map unfreezeParam = new HashMap(4); + unfreezeParam.put("order_no", "1579163031383"); + unfreezeParam.put("app_id", "app_XXXXXXXX"); + unfreezeParam.put("account_freeze_id", "002112020111717230410174704123849117696"); + Map 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 executeUnFreeze(String merchantKey, String app_id, String member_id) throws Exception { + System.out.println("=======execute unfreeze SettleAccount begin======="); + Map unfreezeParam = new HashMap(4); + unfreezeParam.put("order_no", "1579163031384"); + unfreezeParam.put("app_id", "app_XXXXXXXX"); + unfreezeParam.put("account_freeze_id", "002112020111717230410174704123849117696"); + Map 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 executeUnFreezeList(String app_id, String member_id, String settleCount_id) throws Exception { + System.out.println("=======execute query unfreezeList begin======="); + Map 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 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 executeUnFreezeList(String merchantKey, String app_id, String member_id, String settleCount_id) throws Exception { + System.out.println("=======execute query unfreezeList begin======="); + Map 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 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 executeCommission(String app_id, String member_id) throws Exception { + System.out.println("=======execute commissions SettleAccount begin======="); + Map params = new HashMap(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 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 executeCommission(String merchantKey, String app_id, String member_id) throws Exception { + System.out.println("=======execute commissions SettleAccount begin======="); + Map params = new HashMap(4); + params.put("order_no", "1579163031383"); + params.put("payment_id", "002112020111717230410174704123849117696"); + params.put("trans_amt", "0.01"); + System.out.println("创建服务商分账对象,请求参数:" + JSON.toJSONString(params)); + Map 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 executeCommissionList(String app_id) throws Exception { + System.out.println("=======execute query unfreezeList begin======="); + Map 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 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 executeCommissionList(String merchantKey, String app_id) throws Exception { + System.out.println("=======execute query unfreezeList begin======="); + Map 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 result = SettleAccount.commissionList(params,merchantKey); + System.out.println("查询服务商分账对象列表,返回参数:" + JSON.toJSONString(result)); + System.out.println("=======execute query unfreezeList end======="); + return result; + } +}