|
|
|
@@ -93,7 +93,7 @@ public class AliPayUtil { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
private static JSONObject getGenericResponse(String result,String key) { |
|
|
|
private static JSONObject getGenericResponseWithCodes(String result,String key,String[] successCodes) { |
|
|
|
if (StringUtils.isBlank(result)) { |
|
|
|
log.error("alipay apiresponse ["+key+"] error. no result."+result); |
|
|
|
return null; |
|
|
|
@@ -103,8 +103,10 @@ public class AliPayUtil { |
|
|
|
JSONObject resultObject = object.getJSONObject(key); |
|
|
|
if (null != resultObject ) { |
|
|
|
String code = resultObject.getString("code"); |
|
|
|
if (("10000".equals(code))) { |
|
|
|
return resultObject; |
|
|
|
for (String successCode : successCodes) { |
|
|
|
if ((successCode.equals(code))) { |
|
|
|
return resultObject; |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
@@ -112,6 +114,10 @@ public class AliPayUtil { |
|
|
|
return null; |
|
|
|
} |
|
|
|
|
|
|
|
private static JSONObject getGenericResponse(String result,String key) { |
|
|
|
return getGenericResponseWithCodes(result,key,new String[] {"10000"}); |
|
|
|
} |
|
|
|
|
|
|
|
//门店照片上传 |
|
|
|
public String merchantImageUpload(String appAuthToken,String imageName,byte[] file) { |
|
|
|
String temfolder = "/alipaytempfile/"+UUID.randomUUID(); |
|
|
|
@@ -299,10 +305,10 @@ public class AliPayUtil { |
|
|
|
} |
|
|
|
|
|
|
|
//商圈消息订阅 |
|
|
|
public boolean smartDistrictTopicSubscribe(String appAuthToken) { |
|
|
|
public boolean smartDistrictTopicSubscribe(String appAuthToken,String topic) { |
|
|
|
try { |
|
|
|
AlipayOpenApiGenericResponse response = AliPayApi.topicSubscribe(getConfig(),appAuthToken, "app_auth", "alipay.open.auth.appauth.cancelled", "HTTP", "BIZ_TAG"); |
|
|
|
JSONObject result = getGenericResponse(response.getHttpBody(),"alipay_open_app_message_topic_subscribe_response"); |
|
|
|
AlipayOpenApiGenericResponse response = AliPayApi.topicSubscribe(getConfig(),appAuthToken, "app_auth", topic, "HTTP", "BIZ_TAG"); |
|
|
|
JSONObject result = getGenericResponseWithCodes(response.getHttpBody(),"alipay_open_app_message_topic_subscribe_response",new String[] {"40004","10000"}); |
|
|
|
if (null != result) { |
|
|
|
return true; |
|
|
|
} |
|
|
|
@@ -335,17 +341,17 @@ public class AliPayUtil { |
|
|
|
return buffer; |
|
|
|
} |
|
|
|
|
|
|
|
// public static void main(String[] args) { |
|
|
|
// AliPayUtil util = new AliPayUtil(); |
|
|
|
//// String token = getAppAuthToken("Pfbe94a5103a0414db99ce865204ee63"); |
|
|
|
//// System.out.println(token); |
|
|
|
// //File file = new File("C://logo-img.png"); |
|
|
|
// //System.out.println(util.merchantImageUpload("202104BB054c88e950ba4513854e4275ff71cF63", "aa.jpg", File2byte(file))); |
|
|
|
// //System.out.println(util.createSmartDistrictMemberCardModel("202104BB054c88e950ba4513854e4275ff71cF63", "会员卡", "OKJx3oOPTUOaINs0AQ_qMgAAACMAAQQD", "OKJx3oOPTUOaINs0AQ_qMgAAACMAAQQD")); |
|
|
|
// //System.out.println(util.setSmartDistrictMemberCardModelConfig("202104BB054c88e950ba4513854e4275ff71cF63", "20210417000000002702655000300637")); |
|
|
|
// //System.out.println(util.getSmartDistrictMemberCardUrl("202104BB054c88e950ba4513854e4275ff71cF63", "20210417000000002702655000300637", "https://ctest.malls.iformall.com/C/api/alipay/callback", "123")); |
|
|
|
// //System.out.println(util.getH5SmartDistrictMallVipPointsUrl("2021002139648762", "https://ctest.malls.iformall.com/C/api/alipay/callback", "123")); |
|
|
|
// System.out.println(util.smartDistrictTopicSubscribe("202104BB054c88e950ba4513854e4275ff71cF63")); |
|
|
|
// } |
|
|
|
public static void main(String[] args) { |
|
|
|
AliPayUtil util = new AliPayUtil(); |
|
|
|
// String token = getAppAuthToken("Pfbe94a5103a0414db99ce865204ee63"); |
|
|
|
// System.out.println(token); |
|
|
|
//File file = new File("C://logo-img.png"); |
|
|
|
//System.out.println(util.merchantImageUpload("202104BB054c88e950ba4513854e4275ff71cF63", "aa.jpg", File2byte(file))); |
|
|
|
//System.out.println(util.createSmartDistrictMemberCardModel("202104BB054c88e950ba4513854e4275ff71cF63", "会员卡", "OKJx3oOPTUOaINs0AQ_qMgAAACMAAQQD", "OKJx3oOPTUOaINs0AQ_qMgAAACMAAQQD")); |
|
|
|
//System.out.println(util.setSmartDistrictMemberCardModelConfig("202104BB054c88e950ba4513854e4275ff71cF63", "20210417000000002702655000300637")); |
|
|
|
//System.out.println(util.getSmartDistrictMemberCardUrl("202104BB054c88e950ba4513854e4275ff71cF63", "20210417000000002702655000300637", "https://ctest.malls.iformall.com/C/api/alipay/callback", "123")); |
|
|
|
//System.out.println(util.getH5SmartDistrictMallVipPointsUrl("2021002139648762", "https://ctest.malls.iformall.com/C/api/alipay/callback", "123")); |
|
|
|
System.out.println(util.smartDistrictTopicSubscribe("202104BB054c88e950ba4513854e4275ff71cF63","alipay.business.mall.trade.success")); |
|
|
|
} |
|
|
|
|
|
|
|
} |