|
@@ -12,7 +12,10 @@ import com.java110.acct.smo.IQrCodePaymentSMO;
|
|
|
import com.java110.core.factory.CommunitySettingFactory;
|
|
import com.java110.core.factory.CommunitySettingFactory;
|
|
|
import com.java110.utils.cache.MappingCache;
|
|
import com.java110.utils.cache.MappingCache;
|
|
|
import com.java110.utils.constant.WechatConstant;
|
|
import com.java110.utils.constant.WechatConstant;
|
|
|
|
|
+import com.java110.utils.util.StringUtil;
|
|
|
import com.java110.vo.ResultVo;
|
|
import com.java110.vo.ResultVo;
|
|
|
|
|
+import org.slf4j.Logger;
|
|
|
|
|
+import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.stereotype.Service;
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
@@ -20,6 +23,9 @@ import org.springframework.stereotype.Service;
|
|
|
*/
|
|
*/
|
|
|
@Service
|
|
@Service
|
|
|
public class QrCodeAliPaymentAdapt implements IQrCodePaymentSMO {
|
|
public class QrCodeAliPaymentAdapt implements IQrCodePaymentSMO {
|
|
|
|
|
+
|
|
|
|
|
+ private static Logger logger = LoggerFactory.getLogger(QrCodeAliPaymentAdapt.class);
|
|
|
|
|
+
|
|
|
/**
|
|
/**
|
|
|
* APP_ID 应用id
|
|
* APP_ID 应用id
|
|
|
*/
|
|
*/
|
|
@@ -47,6 +53,10 @@ public class QrCodeAliPaymentAdapt implements IQrCodePaymentSMO {
|
|
|
* 格式化
|
|
* 格式化
|
|
|
*/
|
|
*/
|
|
|
public final static String FORMAT = "json";
|
|
public final static String FORMAT = "json";
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 格式化
|
|
|
|
|
+ */
|
|
|
|
|
+ public final static String APP_AUTH_TOKEN = "APP_AUTH_TOKEN";
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* 签名类型
|
|
* 签名类型
|
|
@@ -58,10 +68,13 @@ public class QrCodeAliPaymentAdapt implements IQrCodePaymentSMO {
|
|
|
String systemName = MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, WechatConstant.PAY_GOOD_NAME);
|
|
String systemName = MappingCache.getValue(WechatConstant.WECHAT_DOMAIN, WechatConstant.PAY_GOOD_NAME);
|
|
|
|
|
|
|
|
AlipayClient alipayClient = new DefaultAlipayClient(GETEWAY_URL,
|
|
AlipayClient alipayClient = new DefaultAlipayClient(GETEWAY_URL,
|
|
|
- CommunitySettingFactory.getValue(communityId,"APP_ID"),
|
|
|
|
|
- CommunitySettingFactory.getRemark(communityId,"APP_PRIVATE_KEY"),
|
|
|
|
|
- "json", "utf-8", CommunitySettingFactory.getRemark(communityId,"ALIPAY_PUBLIC_KEY"), "RSA2");
|
|
|
|
|
|
|
+ CommunitySettingFactory.getValue(communityId, "APP_ID"),
|
|
|
|
|
+ CommunitySettingFactory.getRemark(communityId, "APP_PRIVATE_KEY"),
|
|
|
|
|
+ "json", "UTF-8", CommunitySettingFactory.getRemark(communityId, "ALIPAY_PUBLIC_KEY"), "RSA2");
|
|
|
AlipayTradePayRequest request = new AlipayTradePayRequest();
|
|
AlipayTradePayRequest request = new AlipayTradePayRequest();
|
|
|
|
|
+ if (!StringUtil.isEmpty(CommunitySettingFactory.getValue(communityId, APP_AUTH_TOKEN))) {
|
|
|
|
|
+ request.putOtherTextParam("app_auth_token", CommunitySettingFactory.getValue(communityId, APP_AUTH_TOKEN));
|
|
|
|
|
+ }
|
|
|
JSONObject bizContent = new JSONObject();
|
|
JSONObject bizContent = new JSONObject();
|
|
|
bizContent.put("out_trade_no", orderNum);
|
|
bizContent.put("out_trade_no", orderNum);
|
|
|
bizContent.put("total_amount", money);
|
|
bizContent.put("total_amount", money);
|
|
@@ -70,6 +83,7 @@ public class QrCodeAliPaymentAdapt implements IQrCodePaymentSMO {
|
|
|
bizContent.put("auth_code", authCode);
|
|
bizContent.put("auth_code", authCode);
|
|
|
request.setBizContent(bizContent.toString());
|
|
request.setBizContent(bizContent.toString());
|
|
|
AlipayTradePayResponse response = alipayClient.execute(request);
|
|
AlipayTradePayResponse response = alipayClient.execute(request);
|
|
|
|
|
+ logger.debug("支付宝返回:" + JSONObject.toJSONString(response));
|
|
|
if (response.isSuccess()) {
|
|
if (response.isSuccess()) {
|
|
|
System.out.println("调用成功");
|
|
System.out.println("调用成功");
|
|
|
} else {
|
|
} else {
|
|
@@ -88,7 +102,7 @@ public class QrCodeAliPaymentAdapt implements IQrCodePaymentSMO {
|
|
|
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", "app_id", "your private_key", "json", "GBK", "alipay_public_key", "RSA2");
|
|
AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", "app_id", "your private_key", "json", "GBK", "alipay_public_key", "RSA2");
|
|
|
AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
|
|
AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
|
|
|
request.setBizContent("{" +
|
|
request.setBizContent("{" +
|
|
|
- " \"out_trade_no\":\""+orderNum+"\"," +
|
|
|
|
|
|
|
+ " \"out_trade_no\":\"" + orderNum + "\"," +
|
|
|
" \"trade_no\":\"\"," +
|
|
" \"trade_no\":\"\"," +
|
|
|
" \"query_options\":[" +
|
|
" \"query_options\":[" +
|
|
|
" \"trade_settle_info\"" +
|
|
" \"trade_settle_info\"" +
|