本文整理汇总了Java中com.alipay.api.request.AlipayTradeAppPayRequest类的典型用法代码示例。如果您正苦于以下问题:Java AlipayTradeAppPayRequest类的具体用法?Java AlipayTradeAppPayRequest怎么用?Java AlipayTradeAppPayRequest使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AlipayTradeAppPayRequest类属于com.alipay.api.request包,在下文中一共展示了AlipayTradeAppPayRequest类的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: getAlipayAppPayInfo
import com.alipay.api.request.AlipayTradeAppPayRequest; //导入依赖的package包/类
private AlipayPrepayInfo getAlipayAppPayInfo(String tradeNo, String amount, String timeout, String productName, String productDesc, PaymentAccountInfoInterface accountInfo) {
AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
//SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
model.setBody(productDesc);
model.setSubject(productName);
model.setOutTradeNo(tradeNo);
model.setTimeoutExpress(timeout);
model.setTotalAmount(amount);
model.setProductCode("QUICK_MSECURITY_PAY");
request.setBizModel(model);
request.setNotifyUrl(accountInfo.getAliNotifyUrl());
//实例化客户端
AlipayClient alipayClient = getAlipayClient(accountInfo);
try {
//这里和普通的接口调用不同,使用的是sdkExecute
AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
return new AlipayPrepayInfo(null, response.getBody());
} catch (AlipayApiException e) {
e.printStackTrace();
logger.error("Alipay get app pay info failed!");
}
return null;
}
示例2: createAppOrder
import com.alipay.api.request.AlipayTradeAppPayRequest; //导入依赖的package包/类
/**
* app支付
*
* @param subject
* 支付标题
* @param body
* 支付明细
* @param price
* 支付价格(元)
* @param order
* 系统订单号
* @return
*/
public String createAppOrder(String subject, String body, String price, String order) {
String result = "";
AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
model.setBody(body);
model.setSubject(subject);
model.setOutTradeNo(order);
model.setTimeoutExpress("30m");
model.setTotalAmount(price);
request.setBizModel(model);
request.setNotifyUrl(config.getString("NOTIFY_URL"));
try {
AlipayTradeAppPayResponse response = client.sdkExecute(request);
result = response.getBody();
} catch (AlipayApiException e) {
e.printStackTrace();
}
return result;
}
示例3: appPayToResponse
import com.alipay.api.request.AlipayTradeAppPayRequest; //导入依赖的package包/类
/**
* APP支付
* https://doc.open.alipay.com/docs/doc.htm?treeId=54&articleId=106370&docType=1
* @param model
* @param notifyUrl
* @return {AlipayTradeAppPayResponse}
* @throws {AlipayApiException}
*/
public static AlipayTradeAppPayResponse appPayToResponse(AlipayTradeAppPayModel model, String notifyUrl) throws AlipayApiException{
//实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
//SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
request.setBizModel(model);
request.setNotifyUrl(notifyUrl);
//这里和普通的接口调用不同,使用的是sdkExecute
AlipayTradeAppPayResponse response = AliPayApiConfigKit.getAliPayApiConfig().getAlipayClient().sdkExecute(request);
return response;
}
示例4: appPay
import com.alipay.api.request.AlipayTradeAppPayRequest; //导入依赖的package包/类
/**
* App 支付
* @param model
* @param notifyUrl
* @return
* @throws AlipayApiException
*/
public static AlipayTradeAppPayResponse appPay(AlipayTradeAppPayModel model, String notifyUrl)
throws AlipayApiException {
// 实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
// SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
request.setBizModel(model);
request.setNotifyUrl(notifyUrl);
// 这里和普通的接口调用不同,使用的是sdkExecute
AlipayTradeAppPayResponse response = AliPayConfig.build().getAlipayClient().sdkExecute(request);
return response;
}
示例5: getSign
import com.alipay.api.request.AlipayTradeAppPayRequest; //导入依赖的package包/类
/**
* 下单并获取支付签名
* @param out_trade_no 商户订单号
* @param subject 交易主题
* @param body 交易详情
* @param amount 交易金额
* @param ip 客户端IP
* @param timeout 订单失效时间
* @param callBack 回调地址
* @return 支付参数
*/
public static String getSign(String out_trade_no, String subject, String body, BigDecimal amount, String ip,
String timeout, String callBack) {
// 实例化客户端
AlipayClient alipayClient = AliPayConfig.build().getAlipayClient();
// 实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
// SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
model.setSubject(subject);
model.setBody(body);
model.setOutTradeNo(out_trade_no);
model.setTimeoutExpress(timeout);
model.setTotalAmount(amount.toString());
model.setProductCode("QUICK_MSECURITY_PAY");
request.setBizModel(model);
request.setNotifyUrl(callBack);
try {
// 这里和普通的接口调用不同,使用的是sdkExecute
AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
logger.info(response.getBody());// 就是orderString 可以直接给客户端请求,无需再做处理。
if (!response.isSuccess()) {
throw new RuntimeException(response.getSubMsg());
}
return response.getBody();
} catch (AlipayApiException e) {
throw new RuntimeException(e);
}
}
示例6: appPay
import com.alipay.api.request.AlipayTradeAppPayRequest; //导入依赖的package包/类
/**
* App 支付
* https://doc.open.alipay.com/docs/doc.htm?treeId=54&articleId=106370&docType=1
*
* @param model
* @param notifyUrl
* @return
* @throws AlipayApiException
*/
public static AlipayTradeAppPayResponse appPay(AlipayTradeAppPayModel model, String notifyUrl)
throws AlipayApiException {
// 实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
// SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
request.setBizModel(model);
request.setNotifyUrl(notifyUrl);
// 这里和普通的接口调用不同,使用的是sdkExecute
AlipayTradeAppPayResponse response = AliPayConfig.build().getAlipayClient().sdkExecute(request);
return response;
}
示例7: quickMsecurityPay
import com.alipay.api.request.AlipayTradeAppPayRequest; //导入依赖的package包/类
@Override
public String quickMsecurityPay(String key, String user, String subject, int amount, String billNo, String notice) {
AlipayModel alipay = alipayDao.findByKey(key);
String content = getBizContent(alipay.getAppId(), user, subject, amount, billNo, notice, "QUICK_MSECURITY_PAY");
if (content == null)
return null;
AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
request.setBizContent(content);
String string = prepay(alipay, null, request);
return string == null ? null : string.substring(string.indexOf('?') + 1, string.indexOf('>') - 1) + "&biz_content=" +
coder.encodeUrl(string.substring(string.indexOf('{'), string.indexOf('}') + 1)
.replaceAll(""", "\""), null);
}
示例8: doAliPayMobileReq
import com.alipay.api.request.AlipayTradeAppPayRequest; //导入依赖的package包/类
/**
* 支付宝APP支付,生产签名及请求支付宝的参数(注:不会向支付宝发请求)
* 文档: https://docs.open.alipay.com/204/105465/
* @param jsonParam
* @return
*/
@RequestMapping(value = "/pay/channel/ali_mobile")
public String doAliPayMobileReq(@RequestParam String jsonParam) {
String logPrefix = "【支付宝APP支付下单】";
JSONObject paramObj = JSON.parseObject(new String(MyBase64.decode(jsonParam)));
PayOrder payOrder = paramObj.getObject("payOrder", PayOrder.class);
String payOrderId = payOrder.getPayOrderId();
String mchId = payOrder.getMchId();
String channelId = payOrder.getChannelId();
MchInfo mchInfo = mchInfoService.selectMchInfo(mchId);
String resKey = mchInfo == null ? "" : mchInfo.getResKey();
if("".equals(resKey)) return XXPayUtil.makeRetFail(XXPayUtil.makeRetMap(PayConstant.RETURN_VALUE_FAIL, "", PayConstant.RETURN_VALUE_FAIL, PayEnum.ERR_0001));
PayChannel payChannel = payChannelService.selectPayChannel(channelId, mchId);
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);
AlipayTradeAppPayRequest alipay_request = new AlipayTradeAppPayRequest();
// 封装请求支付信息
AlipayTradeAppPayModel model=new AlipayTradeAppPayModel();
model.setOutTradeNo(payOrderId);
model.setSubject(payOrder.getSubject());
model.setTotalAmount(AmountUtil.convertCent2Dollar(payOrder.getAmount().toString()));
model.setBody(payOrder.getBody());
model.setProductCode("QUICK_MSECURITY_PAY");
alipay_request.setBizModel(model);
// 设置异步通知地址
alipay_request.setNotifyUrl(alipayConfig.getNotify_url());
// 设置同步地址
alipay_request.setReturnUrl(alipayConfig.getReturn_url());
String payParams = null;
try {
payParams = client.sdkExecute(alipay_request).getBody();
} catch (AlipayApiException e) {
e.printStackTrace();
}
payOrderService.updateStatus4Ing(payOrderId, null);
_log.info("{}生成请求支付宝数据,payParams={}", logPrefix, payParams);
_log.info("###### 商户统一下单处理完成 ######");
Map<String, Object> map = XXPayUtil.makeRetMap(PayConstant.RETURN_VALUE_SUCCESS, "", PayConstant.RETURN_VALUE_SUCCESS, null);
map.put("payOrderId", payOrderId);
map.put("payParams", payParams);
return XXPayUtil.makeRetData(map, resKey);
}
示例9: doAliPayMobileReq
import com.alipay.api.request.AlipayTradeAppPayRequest; //导入依赖的package包/类
@Override
public Map doAliPayMobileReq(String jsonParam) {
String logPrefix = "【支付宝APP支付下单】";
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 payOrderObj = baseParam.isNullValue("payOrder") ? null : JSONObject.parseObject(bizParamMap.get("payOrder").toString());
PayOrder payOrder = BeanConvertUtils.map2Bean(payOrderObj, PayOrder.class);
if (ObjectValidUtil.isInvalid(payOrder)) {
_log.warn("{}失败, {}. jsonParam={}", logPrefix, RetEnum.RET_PARAM_INVALID.getMessage(), jsonParam);
return RpcUtil.createFailResult(baseParam, RetEnum.RET_PARAM_INVALID);
}
String payOrderId = payOrder.getPayOrderId();
String mchId = payOrder.getMchId();
String channelId = payOrder.getChannelId();
PayChannel payChannel = super.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);
AlipayTradeAppPayRequest alipay_request = new AlipayTradeAppPayRequest();
// 封装请求支付信息
AlipayTradeAppPayModel model=new AlipayTradeAppPayModel();
model.setOutTradeNo(payOrderId);
model.setSubject(payOrder.getSubject());
model.setTotalAmount(AmountUtil.convertCent2Dollar(payOrder.getAmount().toString()));
model.setBody(payOrder.getBody());
model.setProductCode("QUICK_MSECURITY_PAY");
alipay_request.setBizModel(model);
// 设置异步通知地址
alipay_request.setNotifyUrl(alipayConfig.getNotify_url());
// 设置同步地址
alipay_request.setReturnUrl(alipayConfig.getReturn_url());
String payParams = null;
try {
payParams = client.sdkExecute(alipay_request).getBody();
} catch (AlipayApiException e) {
e.printStackTrace();
}
super.baseUpdateStatus4Ing(payOrderId, null);
_log.info("{}生成请求支付宝数据,payParams={}", logPrefix, payParams);
_log.info("###### 商户统一下单处理完成 ######");
Map<String, Object> map = XXPayUtil.makeRetMap(PayConstant.RETURN_VALUE_SUCCESS, "", PayConstant.RETURN_VALUE_SUCCESS, null);
map.put("payOrderId", payOrderId);
map.put("payParams", payParams);
return RpcUtil.createBizResult(baseParam, map);
}