private static final String APP_ID = "2016090900123"; /** * APP_PRIVATE_KEY 这个是rsa_private_key_pkcs8.pem去头和尾得来 */ private static final String APP_PRIVATE_KEY = "MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAOV9Pprtvjb8RgSU\n" + "+IPIDF0mg7ZCfmvZYIIIAR+uTyzJAkAlxIxrH9GeC1/VaOcP4vZkoqsbCmg4cItg\n" + "yvInjwxOTKVT2B78I5gcgO7ju9inDO0X3qRXtNNfgzkSclCHLlEhAkAmkk1dybJw\n" + "C0EdKztRdy2pohiL4PBkhxEAuGMTq1Vf7j4lodEvf9jmXwHutnQp9w7KHA2f3MNj\n" + "ao8XEt5FyMtU"; // 对应该的就是阿里公钥 private static final String ALIPAY_PUBLIC_KEY = "MIGKBgQDDI6d306Q8fIfCOaTXyiUeJHkrIvYISf8sxHi/fEsraprwCtzvzQETrNRwVxLO5jVmRGi60j8Ue1efIlzPXV9je9mkjzOmdssymZkh2QhUrCmZYI/FCEa3/cNMW0QIDAQAB"; public void testPay() throws Exception { //实例化客户端 //默认是UTF-8,也可以写成GBK AlipayClient client = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", APP_ID, APP_PRIVATE_KEY, "json", "UTF-8", ALIPAY_PUBLIC_KEY); //实例化具体API对应的request类,类名称和接口名称对应,当前调用接口名称:alipay.open.public.template.message.industry.modify AlipayOpenPublicTemplateMessageIndustryModifyRequest request = new AlipayOpenPublicTemplateMessageIndustryModifyRequest(); //SDK已经封装掉了公共参数,这里只需要传入业务参数 //此次只是参数展示,未进行字符串转义,实际情况下请转义 request.setBizContent("{" + "\"primary_industry_name\":\"IT科技/IT软件与服务`\"," + "\"primary_industry_code\":\"10001/20102\"," + "\"secondary_industry_code\":\"10001/20102\"," + "\"secondary_industry_name\":\"IT科技/IT软件与服务\"}"); // AlipayOpenPublicTemplateMessageIndustryModifyResponse response = client.execute(request); String response = client.pageExecute(request).getBody(); System.out.println("表单:" + response); // 调用成功,则处理业务逻辑
发布者:全栈程序员-用户IM,转载请注明出处:https://javaforall.cn/100429.html原文链接:https://javaforall.cn
【正版授权,激活自己账号】: Jetbrains全家桶Ide使用,1年售后保障,每天仅需1毛
【官方授权 正版激活】: 官方授权 正版激活 支持Jetbrains家族下所有IDE 使用个人JB账号...