com.alipay.api.domain.AlipayTradeAppPayModel源码实例Demo

类com.alipay.api.domain.AlipayTradeAppPayModel源码实例Demo

下面列出了com.alipay.api.domain.AlipayTradeAppPayModel 类实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

源代码1 项目: anyline   文件: AlipayUtil.java
/** 
 * app支付 
 *  
 * @param subject 支付标题 
 * @param body  支付明细 
 * @param price  支付价格(元) 
 * @param order  系统订单号 
 * @return String
 */ 
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; 
}
 
源代码2 项目: java-pay   文件: AliPayService.java
/**
 * 支付宝App支付
 *
 * @param orderId
 * @param servletRequest
 * @return
 */
public String appPay(Long orderId, HttpServletRequest servletRequest) {
    Order order = orderService.findOne(orderId);
    AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
    // SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
    AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
    model.setBody("描述");
    model.setSubject("商品名称");
    model.setOutTradeNo(order.getOutTradeNo());
    model.setTimeoutExpress("30m");
    model.setTotalAmount(order.getTotalFee().toString());
    model.setProductCode("QUICK_MSECURITY_PAY");
    request.setBizModel(model);
    request.setNotifyUrl(appProperties.getAli().getNotify_url());
    try {
        // 这里和普通的接口调用不同,使用的是sdkExecute
        AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
        //就是orderString 可以直接给客户端请求,无需再做处理。
        log.info("orderString:{}", response.getBody());
        return response.getBody();
    } catch (AlipayApiException e) {
        e.printStackTrace();
    }
    return null;
}
 
@Ignore
public void should_get_app_id_with_load_test_flag_when_call_sdk_execute() throws AlipayApiException {
    //given
    AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
    AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
    model.setBody("我是测试数据");
    model.setSubject("App支付测试");
    model.setTotalAmount("0.01");
    model.setProductCode("QUICK_MSECURITY_PAY");
    model.setOutTradeNo("20170216test01");
    model.setTimeExpire("30m");
    request.setBizModel(model);
    request.setNotifyUrl("http://www.test.notify");
    //when
    AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
    String orderString = response.getBody();
    //then
    assertThat(orderString, containsString("app_id=2021000100600007_TEST_1A"));
}
 
源代码4 项目: NutzSite   文件: PayUtil.java
/**
 * 支付宝订单创建
 * @param out_trade_no 商户订单号,商户网站订单系统中唯一订单号,必填
 * @param subject      订单名称,必填
 * @param total_amount 付款金额,必填
 * @param body         商品描述,可空
 */
public static String createOrder(String out_trade_no, String subject, String total_amount, String body) throws Exception {
    if (Strings.isEmpty(out_trade_no) || Strings.isEmpty(subject) || Strings.isEmpty(total_amount)) {
        throw new Exception("支付宝参数异常");
    }
    AlipayClient alipayClient = new DefaultAlipayClient(AlipayConfig.URL, AlipayConfig.APPID, AlipayConfig.RSA_PRIVATE_KEY,
            AlipayConfig.FORMAT, AlipayConfig.CHARSET, AlipayConfig.ALIPAY_PUBLIC_KEY, AlipayConfig.SIGNTYPE);
    //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay
    AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
    //SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。
    AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
    model.setBody(body);
    model.setSubject(subject);
    model.setOutTradeNo(out_trade_no);
    model.setTimeoutExpress("30m");
    model.setTotalAmount(total_amount);
    model.setProductCode("QUICK_MSECURITY_PAY");
    request.setBizModel(model);
    request.setNotifyUrl(AlipayConfig.notify_url);
    try {
        //这里和普通的接口调用不同,使用的是sdkExecute
        AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request);
        System.out.println(response.getBody());
        return response.getBody();
        //就是orderString 可以直接给客户端请求,无需再做处理。
    } catch (AlipayApiException e) {
        e.printStackTrace();
    }
    return null;
}
 
源代码5 项目: fast-family-master   文件: AlipayAppServiceImpl.java
@Override
public AlipayTradeAppPayResponse createOrder(AlipayTradeAppPayModel model) throws AlipayApiException {
    AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
    request.setBizModel(model);
    request.setNotifyUrl(aliPayProperties.getNotifyUrl());
    return alipayClient.sdkExecute(request);

}
 
源代码6 项目: alipay-sdk-java-all   文件: SDKExecuteTest.java
private AlipayTradeAppPayRequest getTradeAppPayRequest() {
    AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest();
    AlipayTradeAppPayModel model = new AlipayTradeAppPayModel();
    model.setBody("我是测试数据");
    model.setSubject("App支付测试");
    model.setTotalAmount("0.01");
    model.setProductCode("QUICK_MSECURITY_PAY");
    model.setOutTradeNo("20170216test01");
    model.setTimeoutExpress("30m");
    request.setBizModel(model);
    request.setNotifyUrl("http://www.test.notify");
    return request;
}
 
源代码7 项目: alipay   文件: AppPayChain.java
public AppPayChain(AlipayClient alipayClient, AlipayTradeAppPayModel alipayTradeAppPayModel) {
    this.alipayClient = alipayClient;
    this.alipayTradeAppPayModel = alipayTradeAppPayModel;
}
 
源代码8 项目: alipay   文件: AppPayParamChain.java
public AppPayParamChain(AlipayClient alipayClient, AlipayTradeAppPayModel alipayTradeAppPayModel) {
    this.alipayClient = alipayClient;
    this.alipayTradeAppPayModel = alipayTradeAppPayModel;
}
 
源代码9 项目: xxpay-master   文件: PayChannel4AliServiceImpl.java
@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);
}
 
源代码10 项目: xxpay-master   文件: PayChannel4AlipayController.java
/**
 * 支付宝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);
}
 
源代码11 项目: fast-family-master   文件: AlipayAppService.java
AlipayTradeAppPayResponse createOrder(AlipayTradeAppPayModel model) throws AlipayApiException; 
源代码评论
动弹
沙发等你来抢
 类所在包
 类方法
 同包方法