当前位置: 首页>>代码示例>>Java>>正文


Java DefaultAlipayClient类代码示例

本文整理汇总了Java中com.alipay.api.DefaultAlipayClient的典型用法代码示例。如果您正苦于以下问题:Java DefaultAlipayClient类的具体用法?Java DefaultAlipayClient怎么用?Java DefaultAlipayClient使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


DefaultAlipayClient类属于com.alipay.api包,在下文中一共展示了DefaultAlipayClient类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getAccessToken

import com.alipay.api.DefaultAlipayClient; //导入依赖的package包/类
/**
 * 通过code获取token
 * @param payConfig 支付配置
 * @param code   code
 * @return  订单信息
 */
public static String getAccessToken(AliPayConfig payConfig, String code) {
    AlipayClient alipayClient = new DefaultAlipayClient(
            AliPayConfig.URL,
            payConfig.getAppId(),
            payConfig.getAppPrivateKey(),
            AliPayConfig.FORMAT,
            AliPayConfig.CHARSET,
            payConfig.getAlipayPublicKey(),
            payConfig.getSignType());

    AlipayOpenAuthTokenAppRequest request = new AlipayOpenAuthTokenAppRequest();
    request.setBizContent("{" +
            "    \"grant_type\":\"authorization_code\"," +
            "    \"code\":\""+code+"\"" +
            "  }");
    AlipayOpenAuthTokenAppResponse response = null;
    try {
        response = alipayClient.execute(request);
    } catch (AlipayApiException e) {
        logger.error(e.getMessage());
        return null;
    }
    return response.getBody();
}
 
开发者ID:1991wangliang,项目名称:pay,代码行数:31,代码来源:AliPayUtils.java

示例2: queryOrder

import com.alipay.api.DefaultAlipayClient; //导入依赖的package包/类
/**
 * 订单查询接口
 * @param payConfig 支付参数
 * @param orderNo   订单号
 * @return  订单详细
 */
public static String queryOrder(AliPayConfig payConfig, String orderNo,String authToken) {
    AlipayClient alipayClient = new DefaultAlipayClient(
            AliPayConfig.URL,
            payConfig.getAppId(),
            payConfig.getAppPrivateKey(),
            AliPayConfig.FORMAT,
            AliPayConfig.CHARSET,
            payConfig.getAlipayPublicKey(),
            payConfig.getSignType());
    AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
    request.setBizContent("{" +
            "\"out_trade_no\":\""+orderNo+"\""+
            "  }");
    AlipayTradeQueryResponse response = null;
    try {
        response = alipayClient.execute(request,null,authToken);
    } catch (AlipayApiException e) {
        logger.error(e.getMessage());
        return null;
    }
    return response.getBody();

}
 
开发者ID:1991wangliang,项目名称:pay,代码行数:30,代码来源:AliPayUtils.java

示例3: refundOrder

import com.alipay.api.DefaultAlipayClient; //导入依赖的package包/类
/**
 * 退款接口
 * @param payConfig 支付参数
 * @param orderNo   订单号
 * @param refundAmount  退款金额
 * @return
 */
public static String refundOrder(AliPayConfig payConfig, String orderNo, String out_request_no, String authToken,String refundAmount) {
    AlipayClient alipayClient = new DefaultAlipayClient(
            AliPayConfig.URL,
            payConfig.getAppId(),
            payConfig.getAppPrivateKey(),
            AliPayConfig.FORMAT,
            AliPayConfig.CHARSET,
            payConfig.getAlipayPublicKey(),
            payConfig.getSignType());
    AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
    request.setBizContent("{" +
            "\"out_trade_no\":\""+orderNo+"\"," +
            "\"out_request_no\":\""+out_request_no+"\"," +
            "\"refund_amount\":"+refundAmount+"" +
            "  }");
    AlipayTradeRefundResponse response = null;
    try {
        response = alipayClient.execute(request,null,authToken);
    } catch (AlipayApiException e) {
        logger.error(e.getMessage());
        return null;
    }
    return response.getBody();
}
 
开发者ID:1991wangliang,项目名称:pay,代码行数:32,代码来源:AliPayUtils.java

示例4: closeOrder

import com.alipay.api.DefaultAlipayClient; //导入依赖的package包/类
/**
 * 关闭订单
 * @param payConfig 支付配置
 * @param orderNo   订单号
 * @return  订单信息
 */
public static String closeOrder(AliPayConfig payConfig, String orderNo,String authToken) {
    AlipayClient alipayClient = new DefaultAlipayClient(
            AliPayConfig.URL,
            payConfig.getAppId(),
            payConfig.getAppPrivateKey(),
            AliPayConfig.FORMAT,
            AliPayConfig.CHARSET,
            payConfig.getAlipayPublicKey(),
            payConfig.getSignType());

    AlipayTradeCloseRequest request = new AlipayTradeCloseRequest();
    request.setBizContent("{" +
            "\"out_trade_no\":\""+orderNo+"\"" +
            "  }");
    AlipayTradeCloseResponse response = null;
    try {
        response = alipayClient.execute(request,null,authToken);
    } catch (AlipayApiException e) {
        logger.error(e.getMessage());
        return null;
    }
    return response.getBody();
}
 
开发者ID:1991wangliang,项目名称:pay,代码行数:30,代码来源:AliPayUtils.java

示例5: refreshAccessToken

import com.alipay.api.DefaultAlipayClient; //导入依赖的package包/类
/**
 * 刷新token
 * @param payConfig 支付配置
 * @param token   token
 * @return  订单信息
 */
public static String refreshAccessToken(AliPayConfig payConfig, String token) {
    AlipayClient alipayClient = new DefaultAlipayClient(
            AliPayConfig.URL,
            payConfig.getAppId(),
            payConfig.getAppPrivateKey(),
            AliPayConfig.FORMAT,
            AliPayConfig.CHARSET,
            payConfig.getAlipayPublicKey(),
            payConfig.getSignType());

    AlipayOpenAuthTokenAppRequest request = new AlipayOpenAuthTokenAppRequest();
    request.setBizContent("{" +
            "    \"grant_type\":\"refresh_token\"," +
            "    \"refresh_token\":\""+token+"\"" +
            "  }");
    AlipayOpenAuthTokenAppResponse response = null;
    try {
        response = alipayClient.execute(request);
    } catch (AlipayApiException e) {
        logger.error(e.getMessage());
        return null;
    }
    return response.getBody();
}
 
开发者ID:1991wangliang,项目名称:pay,代码行数:31,代码来源:AliPayUtils.java

示例6: queryAccessToken

import com.alipay.api.DefaultAlipayClient; //导入依赖的package包/类
/**
 * 查询订单状态
 * @param payConfig 支付信息
 * @param token token
 * @return
 */
public static String queryAccessToken(AliPayConfig payConfig, String token) {
    AlipayClient alipayClient = new DefaultAlipayClient(
            AliPayConfig.URL,
            payConfig.getAppId(),
            payConfig.getAppPrivateKey(),
            AliPayConfig.FORMAT,
            AliPayConfig.CHARSET,
            payConfig.getAlipayPublicKey(),
            payConfig.getSignType());

    AlipayOpenAuthTokenAppQueryRequest request = new AlipayOpenAuthTokenAppQueryRequest();
    request.setBizContent("{" +
            "    \"app_auth_token\":\""+token+"\"" +
            "  }");
    AlipayOpenAuthTokenAppQueryResponse response = null;
    try {
        response = alipayClient.execute(request);
    } catch (AlipayApiException e) {
        logger.error(e.getMessage());
        return null;
    }
    return response.getBody();
}
 
开发者ID:1991wangliang,项目名称:pay,代码行数:30,代码来源:AliPayUtils.java

示例7: queryOrder

import com.alipay.api.DefaultAlipayClient; //导入依赖的package包/类
/**
 * 订单查询接口
 * @param payConfig 支付参数
 * @param orderNo   订单号
 * @return  订单详细
 */
public static String queryOrder(AliPayConfig payConfig, String orderNo) {
    AlipayClient alipayClient = new DefaultAlipayClient(
            AliPayConfig.URL,
            payConfig.getAppId(),
            payConfig.getAppPrivateKey(),
            AliPayConfig.FORMAT,
            AliPayConfig.CHARSET,
            payConfig.getAlipayPublicKey(),
            payConfig.getSignType());
    AlipayTradeQueryRequest request = new AlipayTradeQueryRequest();
    request.setBizContent("{" +
            "\"out_trade_no\":\""+orderNo+"\""+
            "  }");
    AlipayTradeQueryResponse response = null;
    try {
        response = alipayClient.execute(request);
    } catch (AlipayApiException e) {
        logger.error(e.getMessage());
        return null;
    }
    return response.getBody();

}
 
开发者ID:1991wangliang,项目名称:pay,代码行数:30,代码来源:AliPayUtils.java

示例8: refundOrder

import com.alipay.api.DefaultAlipayClient; //导入依赖的package包/类
/**
 * 退款接口
 * @param payConfig 支付参数
 * @param orderNo   订单号
 * @param refundAmount  退款金额
 * @return
 */
public static String refundOrder(AliPayConfig payConfig, String orderNo,String refundAmount) {
    AlipayClient alipayClient = new DefaultAlipayClient(
            AliPayConfig.URL,
            payConfig.getAppId(),
            payConfig.getAppPrivateKey(),
            AliPayConfig.FORMAT,
            AliPayConfig.CHARSET,
            payConfig.getAlipayPublicKey(),
            payConfig.getSignType());
    AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
    request.setBizContent("{" +
            "\"out_trade_no\":\""+orderNo+"\"," +
            "\"refund_amount\":"+refundAmount+"" +
            "  }");
    AlipayTradeRefundResponse response = null;
    try {
        response = alipayClient.execute(request);
    } catch (AlipayApiException e) {
        logger.error(e.getMessage());
        return null;
    }
    return response.getBody();
}
 
开发者ID:1991wangliang,项目名称:pay,代码行数:31,代码来源:AliPayUtils.java

示例9: closeOrder

import com.alipay.api.DefaultAlipayClient; //导入依赖的package包/类
/**
 * 关闭订单
 * @param payConfig 支付配置
 * @param orderNo   订单号
 * @return  订单信息
 */
public static String closeOrder(AliPayConfig payConfig, String orderNo) {
    AlipayClient alipayClient = new DefaultAlipayClient(
            AliPayConfig.URL,
            payConfig.getAppId(),
            payConfig.getAppPrivateKey(),
            AliPayConfig.FORMAT,
            AliPayConfig.CHARSET,
            payConfig.getAlipayPublicKey(),
            payConfig.getSignType());

    AlipayTradeCloseRequest request = new AlipayTradeCloseRequest();
    request.setBizContent("{" +
            "\"out_trade_no\":\""+orderNo+"\"" +
            "  }");
    AlipayTradeCloseResponse response = null;
    try {
        response = alipayClient.execute(request);
    } catch (AlipayApiException e) {
        logger.error(e.getMessage());
        return null;
    }
    return response.getBody();
}
 
开发者ID:1991wangliang,项目名称:pay,代码行数:30,代码来源:AliPayUtils.java

示例10: refreshAccessToken

import com.alipay.api.DefaultAlipayClient; //导入依赖的package包/类
/**
 * 刷新token
 * @param payConfig 支付配置
 * @param token   token
 * @return  订单信息
 */
public static String refreshAccessToken(AliPayConfig payConfig, String token) {
    AlipayClient alipayClient = new DefaultAlipayClient(
            AliPayConfig.URL,
            payConfig.getAppId(),
            payConfig.getAppPrivateKey(),
            AliPayConfig.FORMAT,
            AliPayConfig.CHARSET,
            payConfig.getAlipayPublicKey(),
            payConfig.getSignType());

    AlipayOpenAuthTokenAppRequest request = new AlipayOpenAuthTokenAppRequest();
    request.setBizContent("{" +
            "    \"grant_type\":\"authorization_code\"," +
            "    \"refresh_token\":\""+token+"\"" +
            "  }");
    AlipayOpenAuthTokenAppResponse response = null;
    try {
        response = alipayClient.execute(request);
    } catch (AlipayApiException e) {
        logger.error(e.getMessage());
        return null;
    }
    return response.getBody();
}
 
开发者ID:1991wangliang,项目名称:pay,代码行数:31,代码来源:AliPayUtils.java

示例11: init

import com.alipay.api.DefaultAlipayClient; //导入依赖的package包/类
@PostConstruct
public void init() {
	alipay = AlipayBuilder.newBuilder(partner, privateKey).build();
	AliPayApiConfig aliPayApiConfig = AliPayApiConfig.New();
	aliPayApiConfig.setAppId(partner);
	aliPayApiConfig.setPrivateKey(privateKey);
	aliPayApiConfig.setAlipayPublicKey(publicKey);
	aliPayApiConfig.setServiceUrl(gatewayUrl);
	aliPayApiConfig.setCharset("UTF-8");
	aliPayApiConfig.setSignType("RSA2");
	aliPayApiConfig.build();
	System.err.println("appId:" + appId);
	System.err.println("gatewayUrl:" + gatewayUrl);
	AliPayApiConfigKit.putApiConfig(aliPayApiConfig);

	alipayClient = new DefaultAlipayClient(gatewayUrl, appId, privateKey, "json", "UTF-8", publicKey, "RSA2");
}
 
开发者ID:tanhaichao,项目名称:leopard,代码行数:18,代码来源:AlipayClientImpl.java

示例12: getInstance

import com.alipay.api.DefaultAlipayClient; //导入依赖的package包/类
public static AlipayUtil getInstance(String key) {
	if (BasicUtil.isEmpty(key)) {
		key = "default";
	}
	AlipayUtil util = instances.get(key);
	if (null == util) {
		util = new AlipayUtil();
		AlipayConfig config = AlipayConfig.getInstance(key);
		util.config = config;
		util.client = new DefaultAlipayClient(
				"https://openapi.alipay.com/gateway.do",
				config.getString("APP_ID"),
				config.getString("APP_PRIVATE_KEY"),
				config.getString("DATA_FORMAT"),
				config.getString("ENCODE"),
				config.getString("ALIPAY_PUBLIC_KEY"),
				config.getString("SIGN_TYPE"));
		instances.put(key, util);
	}

	return util;
}
 
开发者ID:anylineorg,项目名称:anyline,代码行数:23,代码来源:AlipayUtil.java

示例13: barcodePay

import com.alipay.api.DefaultAlipayClient; //导入依赖的package包/类
/**
 * 当面付 : 条码支付
 * @param orderNo  商户订单id
 * @param payCode  用户支付码
 * @param title    订单标题
 * @param storeId  商户id
 * @param totalAmount 总金额
 * @return  支付结果
 */
public static String barcodePay(AliPayConfig payConfig, String orderNo ,String authToken, String  payCode , String title , String storeId , String totalAmount) {
    AlipayClient alipayClient = new DefaultAlipayClient(
            AliPayConfig.URL,
            payConfig.getAppId(),
            payConfig.getAppPrivateKey(),
            AliPayConfig.FORMAT,
            AliPayConfig.CHARSET,
            payConfig.getAlipayPublicKey(),
            payConfig.getSignType());
    AlipayTradePayRequest request = new AlipayTradePayRequest(); //创建API对应的request类
    request.setBizContent("{" +
            "    \"out_trade_no\":\""+orderNo+"\"," +
            "    \"scene\":\"bar_code\"," +
            "    \"auth_code\":\""+payCode+"\"," +
            "    \"subject\":\""+title+"\"," +
            "    \"store_id\":\""+storeId+"\"," +
            "    \"timeout_express\":\"2m\"," +
            "    \"total_amount\":\""+totalAmount+"\"" +
            "  }"); //设置业务参数
    AlipayTradePayResponse response = null; //通过alipayClient调用API,获得对应的response类
    try {
        response = alipayClient.execute(request,null,authToken);
    } catch (AlipayApiException e) {
        logger.error(e.getMessage());
        return null;
    }
    return response.getBody();
}
 
开发者ID:1991wangliang,项目名称:pay,代码行数:38,代码来源:AliPayUtils.java

示例14: barcodePay

import com.alipay.api.DefaultAlipayClient; //导入依赖的package包/类
/**
 * 当面付 : 条码支付
 * @param orderNo  商户订单id
 * @param payCode  用户支付码
 * @param title    订单标题
 * @param storeId  商户id
 * @param totalAmount 总金额
 * @return  支付结果
 */
public static String barcodePay(AliPayConfig payConfig, String orderNo , String  payCode , String title , String storeId , String totalAmount) {
    AlipayClient alipayClient = new DefaultAlipayClient(
            AliPayConfig.URL,
            payConfig.getAppId(),
            payConfig.getAppPrivateKey(),
            AliPayConfig.FORMAT,
            AliPayConfig.CHARSET,
            payConfig.getAlipayPublicKey(),
            payConfig.getSignType());
    AlipayTradePayRequest request = new AlipayTradePayRequest(); //创建API对应的request类
    request.setBizContent("{" +
            "    \"out_trade_no\":\""+orderNo+"\"," +
            "    \"scene\":\"bar_code\"," +
            "    \"auth_code\":\""+payCode+"\"," +
            "    \"subject\":\""+title+"\"," +
            "    \"store_id\":\""+storeId+"\"," +
            "    \"timeout_express\":\"2m\"," +
            "    \"total_amount\":\""+totalAmount+"\"" +
            "  }"); //设置业务参数

    System.out.println(request.getBizContent());
    AlipayTradePayResponse response = null; //通过alipayClient调用API,获得对应的response类
    try {
        response = alipayClient.execute(request);
    } catch (AlipayApiException e) {
        logger.error(e.getMessage());
        return null;
    }
    return response.getBody();
}
 
开发者ID:1991wangliang,项目名称:pay,代码行数:40,代码来源:AliPayUtils.java

示例15: build

import com.alipay.api.DefaultAlipayClient; //导入依赖的package包/类
public AliPayApiConfig build(){
	this.alipayClient = new DefaultAlipayClient(getServiceUrl(), getAppId(), getPrivateKey(), getFormat(), getCharset(), getAlipayPublicKey(),getSignType());
	return this;
}
 
开发者ID:Javen205,项目名称:IJPay,代码行数:5,代码来源:AliPayApiConfig.java


注:本文中的com.alipay.api.DefaultAlipayClient类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。