private static final String APP_ID = "2016090900474";
/**
* APP_PRIVATE_KEY 这个是rsa_private_key_pkcs8.pem去头和尾得来
*/
private static final String APP_PRIVATE_KEY =
"MIICdQIBADANBgkqhkiG9w0BAQEFAASCAl8wggJbAgEAAoGBAOV9Pprtvjb8RgSU\n" +
"z2YKhvDV9OQSAiTMQGV5kbqk70MttkyVfQnyjLyqNLyxhmSlpSUpb8uoWt71LNnO\n" +
"+IPIDF0mg7ZCfmvZYIIIAR+uTyzJAkAlxIxrH9GeC1/VaOcP4vZkoqsbCmg4cItg\n" +
"yvInjwxOTKVT2B78I5gcgO7ju9inDO0X3qRXtNNfgzkSclCHLlEhAkAmkk1dybJw\n" +
"C0EdKztRdy2pohiL4PBkhxEAuGMTq1Vf7j4lodEvf9jmXwHutnQp9w7KHA2f3MNj\n" +
"ao8XEt5FyMtU";
// 对应该的就是阿里公钥
private static final String ALIPAY_PUBLIC_KEY = "MIGKBgQDDI6d306Q8fIfCOaTXyiUeJHkrIvYISRcc73s3vF1ZT7XN8RNPwJxo8pWaJMmvyTn9N4HQ632qJBVHf8sxHi/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);
// 调用成功,则处理业务逻辑
另附支付宝接口说明
https://doc.open.alipay.com/docs/doc.htm?spm=a219a.7629140.0.0.WImN3J&treeId=203&articleId=105285&docType=1