本文整理汇总了Java中com.alipay.api.response.AlipayTradeRefundResponse类的典型用法代码示例。如果您正苦于以下问题:Java AlipayTradeRefundResponse类的具体用法?Java AlipayTradeRefundResponse怎么用?Java AlipayTradeRefundResponse使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AlipayTradeRefundResponse类属于com.alipay.api.response包,在下文中一共展示了AlipayTradeRefundResponse类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。
示例1: refund
import com.alipay.api.response.AlipayTradeRefundResponse; //导入依赖的package包/类
/**
* 支付宝退款接口;
*
* @param bizContent 支付宝退款接口的业务内容请求JSON实例
* @return 是否调用成功
* @author Leibniz
*/
public static boolean refund(RefundBizContent bizContent, Account wxAccount){
String bizContentStr = bizContent.toString(); // 将参数bizContent转成字符串
// 检查bizContent是否合法
if(!bizContent.checkParameters()){
throw new IllegalArgumentException("错误的支付宝退款接口请求业务JSON:" + bizContentStr); // 抛出异常
}
AliAccountInfo aliAccountInfo = new AliAccountInfo(wxAccount.getZfbappid(), wxAccount.getZfbprivkey(), wxAccount.getZfbpubkey(), null, null, null);
AlipayClient alipayClient = AliPayCliFactory.getAlipayClient(aliAccountInfo); // 获取支付宝连接
AlipayTradeRefundRequest request = new AlipayTradeRefundRequest(); // 创建退款请求
request.setBizContent(bizContentStr); // 设置请求的bizContent
AlipayTradeRefundResponse response = null;
try {
response = alipayClient.execute(request); // 发送退款请求并获得响应
} catch (AlipayApiException e) { // 捕捉异常
LOG.error("调用支付宝退款接口时抛出异常,请求的JSON:" + bizContentStr, e); // 打日志
}
// 判断是否有响应
if (response != null) { // 响应成功
// 判断退款是否成功
if (response.isSuccess()) { // 退款成功
LOG.info("调用成功"); // 打日志
return true; // 退款成功
} else { // 退款失败
LOG.error("调用支付宝退款接口错误,code={},msg={},sub_code={},sub_msg={}", new Object[]{response.getCode(), response.getMsg(), response.getSubCode(), response.getSubMsg()}); // 打日志
}
} else { // 响应失败
LOG.error("调用支付宝退款接口时发生异常,返回响应对象为null!{}", bizContentStr); // 打日志
}
return false; // 退款失败
}
开发者ID:Leibnizhu,项目名称:AlipayWechatPlatform,代码行数:43,代码来源:AliPayApi.java
示例2: alipayRefund
import com.alipay.api.response.AlipayTradeRefundResponse; //导入依赖的package包/类
/**
* 支付宝退款接口;
*
* @param bizContent 支付宝退款接口的业务内容请求JSON实例
* @param acc 企业用户账户对象
* 异步返回 是否调用成功
*
* @author Leibniz
*/
public void alipayRefund(RefundBizContent bizContent, JsonObject acc, String successUrl, Handler<Boolean> callback) {
String bizContentStr = bizContent.toString(); // 将参数bizContent转成字符串
// 检查bizContent是否合法
if (!bizContent.checkParameters()) {
throw new IllegalArgumentException("错误的支付宝退款接口请求业务JSON:" + bizContentStr); // 抛出异常
}
String notifyUrl = zfbPayNotifyUrl; // 服务器后台回调通知的url
AliAccountInfo aliAccountInfo = new AliAccountInfo(acc.getString(ZFBAPPID), acc.getString(ZFBPRIVKEY), acc.getString(ZFBPUBKEY), successUrl, notifyUrl, null); // 该对象保存了支付宝账号的相关信息,以及请求回调地址
AlipayClient alipayClient = AliPayCliFactory.getAlipayClient(aliAccountInfo); // 获取支付宝连接
AlipayTradeRefundRequest request = new AlipayTradeRefundRequest(); // 创建退款请求
request.setBizContent(bizContentStr); // 设置请求的bizContent
AlipayTradeRefundResponse response = null;
try {
response = alipayClient.execute(request); // 发送退款请求并获得响应
} catch (AlipayApiException e) { // 捕捉异常
log.error("调用支付宝退款接口时抛出异常,请求的JSON:" + bizContentStr, e); // 打日志
}
// 判断是否有响应
if (response != null) { // 响应成功
// 判断退款是否成功
if (response.isSuccess()) { // 退款成功
log.info("调用成功"); // 打日志
callback.handle(true);
// 退款成功,其他都是错
} else { // 退款失败
log.error("调用支付宝退款接口错误,code={},msg={},sub_code={},sub_msg={}", response.getCode(), response.getMsg(), response.getSubCode(), response.getSubMsg()); // 打日志
callback.handle(false);
}
} else { // 响应失败
log.error("调用支付宝退款接口时发生异常,返回响应对象为null!{}", bizContentStr); // 打日志
callback.handle(false);
}
}
开发者ID:Leibnizhu,项目名称:AlipayWechatPlatform,代码行数:47,代码来源:AlipayPayService.java
示例3: refund
import com.alipay.api.response.AlipayTradeRefundResponse; //导入依赖的package包/类
/**
* 退款
* @param outTradeNo 订单支付时传入的商户订单号,不能和 trade_no同时为空。
* @param tradeNo 支付宝交易号,和商户订单号不能同时为空
* @param outRequestNo 标识一次退款请求,同一笔交易多次退款需要保证唯一,如需部分退款,则此参数必传。
* @param refundAmount 退款金额
* @param refundReason 退款原因
* @return 支付参数
*/
public static RefundResult refund(String outTradeNo, String tradeNo, String outRequestNo, BigDecimal refundAmount,
String refundReason) {
// 实例化客户端
AlipayClient alipayClient = AliPayConfig.build().getAlipayClient();
// 实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
// SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
AlipayTradeRefundModel model = new AlipayTradeRefundModel();
model.setOutTradeNo(outTradeNo);
model.setTradeNo(tradeNo);
model.setRefundAmount(refundAmount.toString());
model.setRefundReason(refundReason);
model.setOutRequestNo(outRequestNo);
request.setBizModel(model);
try {
// 这里和普通的接口调用不同,使用的是sdkExecute
AlipayTradeRefundResponse response = alipayClient.execute(request);
logger.info(response.getBody());
if (!response.isSuccess()) {
throw new RuntimeException(response.getSubMsg());
}
Map<?, ?> body = JSON.parseObject(response.getBody(), Map.class);
Map<?, ?> result = JSON.parseObject(body.get("alipay_trade_refund_response").toString());
return new RefundResult((String)result.get("trade_no"), outTradeNo, refundAmount.toString(),
DateUtil.stringToDate((String)result.get("gmt_refund_pay")),
"Y".equals(result.get("fund_change")) ? "1" : "2");
} catch (AlipayApiException e) {
throw new RuntimeException(e);
}
}
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:40,代码来源:AlipayUtil.java
示例4: tradeRefundToResponse
import com.alipay.api.response.AlipayTradeRefundResponse; //导入依赖的package包/类
public static AlipayTradeRefundResponse tradeRefundToResponse(AlipayTradeRefundModel model)
throws AlipayApiException {
AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
request.setBizModel(model);
return AliPayConfig.build().getAlipayClient().execute(request);
}
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:7,代码来源:AliPay.java
示例5: tradeRefundToResponse
import com.alipay.api.response.AlipayTradeRefundResponse; //导入依赖的package包/类
public static AlipayTradeRefundResponse tradeRefundToResponse(AlipayTradeRefundModel model)
throws AlipayApiException {
AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
request.setBizModel(model);
return AliPayConfig.build().getAlipayClient().execute(request);
}
开发者ID:guokezheng,项目名称:automat,代码行数:7,代码来源:AliPay.java
示例6: getResponseClass
import com.alipay.api.response.AlipayTradeRefundResponse; //导入依赖的package包/类
public Class<AlipayTradeRefundResponse> getResponseClass() {
return AlipayTradeRefundResponse.class;
}
开发者ID:wendal,项目名称:alipay-sdk,代码行数:4,代码来源:AlipayTradeRefundRequest.java
示例7: doAliRefundReq
import com.alipay.api.response.AlipayTradeRefundResponse; //导入依赖的package包/类
@Override
public Map doAliRefundReq(String jsonParam) {
String logPrefix = "【支付宝退款】";
BaseParam baseParam = JsonUtil.getObjectFromJson(jsonParam, BaseParam.class);
Map<String, Object> bizParamMap = baseParam.getBizParamMap();
if (ObjectValidUtil.isInvalid(bizParamMap)) {
_log.warn("{}失败, {}. jsonParam={}", logPrefix, RetEnum.RET_PARAM_NOT_FOUND.getMessage(), jsonParam);
return RpcUtil.createFailResult(baseParam, RetEnum.RET_PARAM_NOT_FOUND);
}
JSONObject refundOrderObj = baseParam.isNullValue("refundOrder") ? null : JSONObject.parseObject(bizParamMap.get("refundOrder").toString());
RefundOrder refundOrder = JSON.toJavaObject(refundOrderObj, RefundOrder.class);
if (ObjectValidUtil.isInvalid(refundOrder)) {
_log.warn("{}失败, {}. jsonParam={}", logPrefix, RetEnum.RET_PARAM_INVALID.getMessage(), jsonParam);
return RpcUtil.createFailResult(baseParam, RetEnum.RET_PARAM_INVALID);
}
String refundOrderId = refundOrder.getRefundOrderId();
String mchId = refundOrder.getMchId();
String channelId = refundOrder.getChannelId();
PayChannel payChannel = baseService4PayOrder.baseSelectPayChannel(mchId, channelId);
alipayConfig.init(payChannel.getParam());
AlipayClient client = new DefaultAlipayClient(alipayConfig.getUrl(), alipayConfig.getApp_id(), alipayConfig.getRsa_private_key(), AlipayConfig.FORMAT, AlipayConfig.CHARSET, alipayConfig.getAlipay_public_key(), AlipayConfig.SIGNTYPE);
AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
AlipayTradeRefundModel model = new AlipayTradeRefundModel();
model.setOutTradeNo(refundOrder.getPayOrderId());
model.setTradeNo(refundOrder.getChannelPayOrderNo());
model.setOutRequestNo(refundOrderId);
model.setRefundAmount(AmountUtil.convertCent2Dollar(refundOrder.getRefundAmount().toString()));
model.setRefundReason("正常退款");
request.setBizModel(model);
Map<String, Object> map = new HashMap<>();
map.put("refundOrderId", refundOrderId);
map.put("isSuccess", false);
try {
AlipayTradeRefundResponse response = client.execute(request);
if(response.isSuccess()){
map.put("isSuccess", true);
map.put("channelOrderNo", response.getTradeNo());
}else {
_log.info("{}返回失败", logPrefix);
_log.info("sub_code:{},sub_msg:{}", response.getSubCode(), response.getSubMsg());
map.put("channelErrCode", response.getSubCode());
map.put("channelErrMsg", response.getSubMsg());
}
} catch (AlipayApiException e) {
_log.error(e, "");
}
return RpcUtil.createBizResult(baseParam, map);
}
开发者ID:jmdhappy,项目名称:xxpay-master,代码行数:49,代码来源:PayChannel4AliServiceImpl.java
示例8: tradeRefund
import com.alipay.api.response.AlipayTradeRefundResponse; //导入依赖的package包/类
/**
* 退款
* https://doc.open.alipay.com/docs/api.htm?spm=a219a.7395905.0.0.SAyEeI&docType=4&apiId=759
* @param model
* @return {String}
* @throws {AlipayApiException}
*/
public static String tradeRefund(AlipayTradeRefundModel model) throws AlipayApiException{
AlipayTradeRefundResponse response = tradeRefundToResponse(model);
return response.getBody();
}
开发者ID:Javen205,项目名称:IJPay,代码行数:12,代码来源:AliPayApi.java
示例9: tradeRefundToResponse
import com.alipay.api.response.AlipayTradeRefundResponse; //导入依赖的package包/类
/**
* 退款
* @param model
* @return {AlipayTradeRefundResponse}
* @throws {AlipayApiException}
*/
public static AlipayTradeRefundResponse tradeRefundToResponse(AlipayTradeRefundModel model) throws AlipayApiException{
AlipayTradeRefundRequest request = new AlipayTradeRefundRequest();
request.setBizModel(model);
return AliPayApiConfigKit.getAliPayApiConfig().getAlipayClient().execute(request);
}
开发者ID:Javen205,项目名称:IJPay,代码行数:12,代码来源:AliPayApi.java
示例10: tradeRefund
import com.alipay.api.response.AlipayTradeRefundResponse; //导入依赖的package包/类
/**
* 退款
*
* @param model content
* @return
* @throws AlipayApiException
*/
public static String tradeRefund(AlipayTradeRefundModel model) throws AlipayApiException {
AlipayTradeRefundResponse response = tradeRefundToResponse(model);
return response.getBody();
}
开发者ID:iBase4J,项目名称:iBase4J-Common,代码行数:12,代码来源:AliPay.java
示例11: tradeRefund
import com.alipay.api.response.AlipayTradeRefundResponse; //导入依赖的package包/类
/**
* 退款
* https://doc.open.alipay.com/docs/api.htm?spm=a219a.7395905.0.0.SAyEeI&docType=4&apiId=759
*
* @param content
* @return
* @throws AlipayApiException
*/
public static String tradeRefund(AlipayTradeRefundModel model) throws AlipayApiException {
AlipayTradeRefundResponse response = tradeRefundToResponse(model);
return response.getBody();
}
开发者ID:guokezheng,项目名称:automat,代码行数:13,代码来源:AliPay.java
注:本文中的com.alipay.api.response.AlipayTradeRefundResponse类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论