com.alipay.api.response.AlipayTradeAppPayResponse Java Examples
The following examples show how to use
com.alipay.api.response.AlipayTradeAppPayResponse.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: AlipayUtil.java From anyline with Apache License 2.0 | 6 votes |
/** * 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; }
Example #2
Source File: AliPayService.java From java-pay with Apache License 2.0 | 6 votes |
/** * 支付宝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; }
Example #3
Source File: LoadTestAlipayClientTest.java From alipay-sdk-java-all with Apache License 2.0 | 6 votes |
@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")); }
Example #4
Source File: AliAppTradePayImpl.java From common-project with Apache License 2.0 | 6 votes |
@Override public AliTradePayResponse createTradePay(AliTradeAppPayParams aliTradeAppPayParams) throws Exception { AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",aliPayConfig.getAppId(),aliPayConfig.getAppPrivateKey(),"json",aliPayConfig.getCharset(),aliPayConfig.getAliPayPublicKey(),aliPayConfig.getSignType()); AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest(); request.setNotifyUrl(aliTradeAppPayParams.getNotifyUrl()); Map<String,Object> bizContent = new HashMap<>(); bizContent.put("total_amount", aliTradeAppPayParams.getTotalAmount()); bizContent.put("subject", aliTradeAppPayParams.getSubject()); bizContent.put("out_trade_no", aliTradeAppPayParams.getOutTradeNo()); request.setBizContent(JSON.toJSONString(bizContent)); AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request); if(!response.isSuccess()){ return null; } logger.info("支付宝APP统一下单成功"); return AliTradePayResponse.generator(response); }
Example #5
Source File: PayUtil.java From NutzSite with Apache License 2.0 | 5 votes |
/** * 支付宝订单创建 * @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; }
Example #6
Source File: AlipayAppServiceImpl.java From fast-family-master with Apache License 2.0 | 5 votes |
@Override public AlipayTradeAppPayResponse createOrder(AlipayTradeAppPayModel model) throws AlipayApiException { AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest(); request.setBizModel(model); request.setNotifyUrl(aliPayProperties.getNotifyUrl()); return alipayClient.sdkExecute(request); }
Example #7
Source File: SDKExecuteTest.java From alipay-sdk-java-all with Apache License 2.0 | 5 votes |
@Test public void should_return_correct_signed_order_string() throws AlipayApiException { //given AlipayTradeAppPayRequest request = getTradeAppPayRequest(); //when AlipayTradeAppPayResponse response = client.sdkExecute(request); String orderString = response.getBody(); //then //必须拥有正确的签名串 assertThat(orderString, containsString("&sign=")); }
Example #8
Source File: SDKExecuteTest.java From alipay-sdk-java-all with Apache License 2.0 | 5 votes |
@Test public void should_return_order_string_with_app_auth_token() throws AlipayApiException { //given AlipayTradeAppPayRequest request = getTradeAppPayRequest(); request.putOtherTextParam("app_auth_token", "123"); //when AlipayTradeAppPayResponse response = client.sdkExecute(request); String orderString = response.getBody(); //then //必须含有app_auth_tokne参数 assertThat(orderString, containsString("app_auth_token=123")); }
Example #9
Source File: SDKExecuteTest.java From alipay-sdk-java-all with Apache License 2.0 | 5 votes |
@Test public void should_return_order_string_with_correct_order_of_parameters() throws AlipayApiException { //given AlipayTradeAppPayRequest request = getTradeAppPayRequest(); request.putOtherTextParam("A", "test"); request.putOtherTextParam("a", "test"); //when AlipayTradeAppPayResponse response = client.sdkExecute(request); String orderString = response.getBody(); //then //大写字符必须在小写字符前面 assertThat(orderString, containsString("A=test&a=test")); }
Example #10
Source File: AliTradePayResponse.java From common-project with Apache License 2.0 | 5 votes |
public static AliTradePayResponse generator(AlipayTradeAppPayResponse alipayTradeAppPayResponse){ AliTradePayResponse aliTradePayResponse = new AliTradePayResponse(); aliTradePayResponse.setOutTradeNo(alipayTradeAppPayResponse.getOutTradeNo()); aliTradePayResponse.setTotalAmount(alipayTradeAppPayResponse.getTotalAmount()); aliTradePayResponse.setTradeNo(alipayTradeAppPayResponse.getOutTradeNo()); aliTradePayResponse.setMerchantOrderNo(alipayTradeAppPayResponse.getMerchantOrderNo()); aliTradePayResponse.setSellerId(alipayTradeAppPayResponse.getSellerId()); return null; }
Example #11
Source File: AlipayTradeAppPayRequest.java From alipay-sdk-java-all with Apache License 2.0 | 4 votes |
public Class<AlipayTradeAppPayResponse> getResponseClass() { return AlipayTradeAppPayResponse.class; }
Example #12
Source File: AlipayTradeAppPayRequest.java From alipay-sdk-java-all with Apache License 2.0 | 4 votes |
public Class<AlipayTradeAppPayResponse> getResponseClass() { return AlipayTradeAppPayResponse.class; }
Example #13
Source File: AlipayTradeAppPayRequest.java From alipay-sdk with Apache License 2.0 | 4 votes |
public Class<AlipayTradeAppPayResponse> getResponseClass() { return AlipayTradeAppPayResponse.class; }
Example #14
Source File: AlipayTradeAppPayRequest.java From pay with Apache License 2.0 | 4 votes |
public Class<AlipayTradeAppPayResponse> getResponseClass() { return AlipayTradeAppPayResponse.class; }
Example #15
Source File: AlipayAppService.java From fast-family-master with Apache License 2.0 | votes |
AlipayTradeAppPayResponse createOrder(AlipayTradeAppPayModel model) throws AlipayApiException;