支付宝退款Api

项目中用到的支付宝退款

	@RequestMapping("/getAlipayZ")
	@ResponseBody
	public static  String getAlipayZ() {

		AlipayClient alipayClient = new DefaultAlipayClient("https://openapi.alipay.com/gateway.do", APP_ID,APP_PRIVATE_KEY, "json", "GBK", ALIPAY_PUBLIC_KEY, "RSA2");
		AlipayTradeRefundRequest requests = new AlipayTradeRefundRequest();
		AlipayTradeRefundModel bizModel = new AlipayTradeRefundModel();
		bizModel.setOutTradeNo(outTradeNo);
		//bizModel.setTradeNo(tradeNo);
 		bizModel.setRefundAmount(RefundAmount);
		  

		Boolean flag =new Boolean(false);
		requests.setBizModel(bizModel);
	
		AlipayTradeRefundResponse response = null;
		try {
			response = alipayClient.execute(requests);

			if (response.isSuccess()) {
				flag = true;
				System.out.println("成功");
				return response.getBody();
			} else {
				System.out.println("失败");
				flag = false;
				return response.getBody();
			}
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
			System.out.println("异常");
			flag = false;
			return response.getBody();
		}
	}

}

你可能感兴趣的:(随笔)