标签:order security gate color for 安卓 trace client 方式
支付宝支付demo
这个是java后台调起支付的demo,直接将body返回给安卓端即可调起支付
1 package com.dyy.test; 2 3 import java.text.SimpleDateFormat; 4 import java.util.Date; 5 import com.alipay.api.AlipayApiException; 6 import com.alipay.api.AlipayClient; 7 import com.alipay.api.DefaultAlipayClient; 8 import com.alipay.api.domain.AlipayTradeAppPayModel; 9 import com.alipay.api.request.AlipayTradeAppPayRequest; 10 import com.alipay.api.response.AlipayTradeAppPayResponse; 11 12 public class TestZhiFu { 13 /** 14 * 支付宝方面订单号获取 15 * @param aliPrepayReq 16 * @return 17 * @throws OperationFailedException 18 */ 19 //private static final String Logger = ""; 20 private static final String APP_ID= "appid"; 21 private static final String APP_PRIVATE_KEY = "秘钥"; 22 private static final String ALIPAY_PUBLIC_KEY = "公钥"; 23 public static void main(String[] args) throws AlipayApiException { 24 TestZhiFu.APPqm();//生成订单 25 // AppServers.chenggong(); 26 } 27 28 //服务端生成订单的接口 29 30 public static void APPqm() { 31 String out_trade_no=new SimpleDateFormat("yyyymmddmmhhss").format(new Date());//产生一组随机的订单号 32 //实例化客户端 33 AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do",APP_ID,APP_PRIVATE_KEY,"json","UTF-8",ALIPAY_PUBLIC_KEY,"RSA2"); 34 //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.trade.app.pay 35 AlipayTradeAppPayRequest request = new AlipayTradeAppPayRequest(); 36 //SDK已经封装掉了公共参数,这里只需要传入业务参数。以下方法为sdk的model入参方式(model和biz_content同时存在的情况下取biz_content)。 37 AlipayTradeAppPayModel model = new AlipayTradeAppPayModel(); 38 model.setBody("清扬洗发水"); 39 model.setSubject("洗发水"); 40 model.setOutTradeNo("20171110191203"); 41 model.setTimeoutExpress("90m"); 42 model.setTotalAmount("1.00"); 43 model.setProductCode("QUICK_MSECURITY_PAY"); 44 request.setBizModel(model); 45 request.setNotifyUrl("回调地址");//商户外网可以访问的异步地址,不能重定向 46 try { 47 //这里和普通的接口调用不同,使用的是sdkExecute 48 AlipayTradeAppPayResponse response = alipayClient.sdkExecute(request); 49 //就是orderString 可以直接给客户端请求,无需再做处理。 50 System.out.println(response.getBody()); 51 } catch (AlipayApiException e) { 52 e.printStackTrace(); 53 } 54 } 55 56 }
标签:order security gate color for 安卓 trace client 方式
原文地址:http://www.cnblogs.com/zique/p/7965390.html