支付宝支付生成二维码图片
// AlipayClient alipayClient1 = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", "你的APPID", private_key, "json", "utf-8", alipay_public_key, "RSA2"); AlipayTradePrecr
·
//
AlipayClient alipayClient1 = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", "你的APPID", private_key, "json", "utf-8", alipay_public_key, "RSA2");
AlipayTradePrecreateRequest request1 = new AlipayTradePrecreateRequest();
request1.setBizContent("{" + "\"out_trade_no\":\"" + scanPaySweepDate.getOut_trade_no() + "\","
// + "\"seller_id\":\"" + scanPaySweepDate.getSeller_id() + "\","
+ "\"total_amount\":" + scanPaySweepDate.getTotal_amount() + ","
+ "\"subject\":\"" + scanPaySweepDate.getSubject() + "\","
// + "\"body\":\"" + scanPaySweepDate.getBody() + "\","
// + "\"operator_id\":\"" + scanPaySweepDate.getOperator_id() + "\","
// + "\"store_id\":\"" + scanPaySweepDate.getStore_id() + "\","
// + "\"terminal_id\":\"" + scanPaySweepDate.getTerminal_id() + "\","
+ "\"timeout_express\":\"" + scanPaySweepDate.getTimeout_express()
+ "\"}");
AlipayTradePrecreateResponse response1 = alipayClient1.execute(request1);
if (response1.isSuccess()) {
System.out.println(response1.getSubMsg());
ScanPayReturningData.getInstance().setOut_trade_no(response1.getOutTradeNo());
ScanPayReturningData.getInstance().setQr_code(response1.getQrCode());
path = "http://qr.liantu.com/api.php?text=" + response1.getQrCode();
t = new Thread(new Runnable() {
@Override
public void run() {
URL url;
try {
url = new URL(path);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setConnectTimeout(5 * 1000);
InputStream inputStream = conn.getInputStream();
byte[] data = readInputStream(inputStream);
File imageFile = new File("D:\\carparkdata\\photo\\zfb.jpg");
FileOutputStream outStream = new FileOutputStream(imageFile);
outStream.write(data);
outStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
});
t.start();
} else {
System.out.println(response1.getSubMsg());
}
AlipayClient alipayClient1 = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", "你的APPID", private_key, "json", "utf-8", alipay_public_key, "RSA2");
AlipayTradePrecreateRequest request1 = new AlipayTradePrecreateRequest();
request1.setBizContent("{" + "\"out_trade_no\":\"" + scanPaySweepDate.getOut_trade_no() + "\","
// + "\"seller_id\":\"" + scanPaySweepDate.getSeller_id() + "\","
+ "\"total_amount\":" + scanPaySweepDate.getTotal_amount() + ","
+ "\"subject\":\"" + scanPaySweepDate.getSubject() + "\","
// + "\"body\":\"" + scanPaySweepDate.getBody() + "\","
// + "\"operator_id\":\"" + scanPaySweepDate.getOperator_id() + "\","
// + "\"store_id\":\"" + scanPaySweepDate.getStore_id() + "\","
// + "\"terminal_id\":\"" + scanPaySweepDate.getTerminal_id() + "\","
+ "\"timeout_express\":\"" + scanPaySweepDate.getTimeout_express()
+ "\"}");
AlipayTradePrecreateResponse response1 = alipayClient1.execute(request1);
if (response1.isSuccess()) {
System.out.println(response1.getSubMsg());
ScanPayReturningData.getInstance().setOut_trade_no(response1.getOutTradeNo());
ScanPayReturningData.getInstance().setQr_code(response1.getQrCode());
path = "http://qr.liantu.com/api.php?text=" + response1.getQrCode();
t = new Thread(new Runnable() {
@Override
public void run() {
URL url;
try {
url = new URL(path);
HttpURLConnection conn = (HttpURLConnection) url.openConnection();
conn.setRequestMethod("GET");
conn.setConnectTimeout(5 * 1000);
InputStream inputStream = conn.getInputStream();
byte[] data = readInputStream(inputStream);
File imageFile = new File("D:\\carparkdata\\photo\\zfb.jpg");
FileOutputStream outStream = new FileOutputStream(imageFile);
outStream.write(data);
outStream.close();
} catch (Exception e) {
e.printStackTrace();
}
}
});
t.start();
} else {
System.out.println(response1.getSubMsg());
}
更多推荐
已为社区贡献1条内容
所有评论(0)