本文整理汇总了Java中com.alipay.config.AlipayConfig类的典型用法代码示例。如果您正苦于以下问题:Java AlipayConfig类的具体用法?Java AlipayConfig怎么用?Java AlipayConfig使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
AlipayConfig类属于com.alipay.config包,在下文中一共展示了AlipayConfig类的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: buildRequestMysign
import com.alipay.config.AlipayConfig; //导入依赖的package包/类
/**
* 生成签名结果
* @param sPara 要签名的数组
* @return 签名结果字符串
*/
public static String buildRequestMysign(Map<String, String> sPara) {
String prestr = AlipayCore.createLinkString(sPara); //把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
String mysign = "";
if(AlipayConfig.sign_type.equals("MD5") ) {
mysign = MD5.sign(prestr, AlipayConfig.key, AlipayConfig.input_charset);
}else if(AlipayConfig.sign_type.equals("RSA") ){
mysign = RSA.sign(prestr, AlipayConfig.private_key, AlipayConfig.input_charset);
}
return mysign;
}
示例2: buildRequest
import com.alipay.config.AlipayConfig; //导入依赖的package包/类
/**
* 建立请求,以表单HTML形式构造(默认)
* @param sParaTemp 请求参数数组
* @param strMethod 提交方式。两个值可选:post、get
* @param strButtonName 确认按钮显示文字
* @return 提交表单HTML文本
*/
public static String buildRequest(Map<String, String> sParaTemp, String strMethod, String strButtonName) {
//待请求参数数组
Map<String, String> sPara = buildRequestPara(sParaTemp);
List<String> keys = new ArrayList<String>(sPara.keySet());
StringBuffer sbHtml = new StringBuffer();
sbHtml.append("<form id=\"alipaysubmit\" name=\"alipaysubmit\" action=\"" + ALIPAY_GATEWAY_NEW
+ "_input_charset=" + AlipayConfig.input_charset + "\" method=\"" + strMethod
+ "\">");
for (int i = 0; i < keys.size(); i++) {
String name = (String) keys.get(i);
String value = (String) sPara.get(name);
sbHtml.append("<input type=\"hidden\" name=\"" + name + "\" value=\"" + value + "\"/>");
}
//submit按钮控件请不要含有name属性
sbHtml.append("<input type=\"submit\" value=\"" + strButtonName + "\" style=\"display:none;\"></form>");
sbHtml.append("<script>document.forms['alipaysubmit'].submit();</script>");
return sbHtml.toString();
}
示例3: query_timestamp
import com.alipay.config.AlipayConfig; //导入依赖的package包/类
/**
* 用于防钓鱼,调用接口query_timestamp来获取时间戳的处理函数
* 注意:远程解析XML出错,与服务器是否支持SSL等配置有关
* @return 时间戳字符串
* @throws IOException
* @throws DocumentException
* @throws MalformedURLException
*/
public static String query_timestamp() throws MalformedURLException,
DocumentException, IOException {
//构造访问query_timestamp接口的URL串
String strUrl = ALIPAY_GATEWAY_NEW + "service=query_timestamp&partner=" + AlipayConfig.partner + "&_input_charset" +AlipayConfig.input_charset;
StringBuffer result = new StringBuffer();
SAXReader reader = new SAXReader();
Document doc = reader.read(new URL(strUrl).openStream());
List<Node> nodeList = doc.selectNodes("//alipay/*");
for (Node node : nodeList) {
// 截取部分不需要解析的信息
if (node.getName().equals("is_success") && node.getText().equals("T")) {
// 判断是否有成功标示
List<Node> nodeList1 = doc.selectNodes("//response/timestamp/*");
for (Node node1 : nodeList1) {
result.append(node1.getText());
}
}
}
return result.toString();
}
示例4: buildRequest
import com.alipay.config.AlipayConfig; //导入依赖的package包/类
/**
* 建立请求,以表单HTML形式构造(默认)
* @param sParaTemp 请求参数数组
* @param strMethod 提交方式。两个值可选:post、get
* @param strButtonName 确认按钮显示文字
* @return 提交表单HTML文本
*/
public static String buildRequest(Map<String, String> sParaTemp, String strMethod, String strButtonName) {
//待请求参数数组
Map<String, String> sPara = buildRequestPara(sParaTemp);
List<String> keys = new ArrayList<String>(sPara.keySet());
StringBuffer sbHtml = new StringBuffer();
sbHtml.append("<form id=\"formAlipay\" name=\"alipaysubmit\" action=\"" + ALIPAY_GATEWAY_NEW
+ "_input_charset=" + AlipayConfig.input_charset + "\" method=\"" + strMethod
+ "\" target=\"_blank\">");
for (int i = 0; i < keys.size(); i++) {
String name = keys.get(i);
String value = sPara.get(name);
sbHtml.append("<input type=\"hidden\" name=\"" + name + "\" value=\"" + value + "\"/>");
}
sbHtml.append("</form>");
//submit按钮控件请不要含有name属性
// sbHtml.append("<input type=\"submit\" value=\"" + strButtonName + "\" style=\"display:none;\"></form>");
// sbHtml.append("<script>document.forms['alipaysubmit'].submit();</script>");
return sbHtml.toString();
}
示例5: PayService
import com.alipay.config.AlipayConfig; //导入依赖的package包/类
public PayService() {
AlipayConfig.partner = CommonConfig.ALIPAY_PARTNER;
AlipayConfig.seller_id = CommonConfig.ALIPAY_SELLER_ID;
AlipayConfig.notify_url = CommonConfig.ALIPAY_NOTIFY_URL;
AlipayConfig.return_url = CommonConfig.ALIPAY_RETURN_URL;
AlipayConfig.key = CommonConfig.ALIPAY_KEY;
AlipayConfig.sign_type = CommonConfig.ALIPAY_ENCRYPT_TYPE;
AlipayConfig.private_key = CommonConfig.ALIPAY_PRIVATE_KEY;
AlipayConfig.alipay_public_key = CommonConfig.ALIPAY_ALIPAY_PUBLIC_KEY;
}
示例6: getStringResult
import com.alipay.config.AlipayConfig; //导入依赖的package包/类
public String getStringResult() throws UnsupportedEncodingException {
if (stringResult != null) {
return stringResult;
}
if (byteResult != null) {
return new String(byteResult, AlipayConfig.input_charset);
}
return null;
}
示例7: buildRequestPara
import com.alipay.config.AlipayConfig; //导入依赖的package包/类
/**
* 生成要请求给支付宝的参数数组
* @param sParaTemp 请求前的参数数组
* @return 要请求的参数数组
*/
private static Map<String, String> buildRequestPara(Map<String, String> sParaTemp) {
//除去数组中的空值和签名参数
Map<String, String> sPara = AlipayCore.paraFilter(sParaTemp);
//生成签名结果
String mysign = buildRequestMysign(sPara);
//签名结果与签名方式加入请求提交参数组中
sPara.put("sign", mysign);
sPara.put("sign_type", AlipayConfig.sign_type);
return sPara;
}
示例8: getSignVeryfy
import com.alipay.config.AlipayConfig; //导入依赖的package包/类
/**
* 根据反馈回来的信息,生成签名结果
* @param Params 通知返回来的参数数组
* @param sign 比对的签名结果
* @return 生成的签名结果
*/
private static boolean getSignVeryfy(Map<String, String> Params, String sign) {
//过滤空值、sign与sign_type参数
Map<String, String> sParaNew = AlipayCore.paraFilter(Params);
//获取待签名字符串
String preSignStr = AlipayCore.createLinkString(sParaNew);
//获得签名验证结果
boolean isSign = false;
if(AlipayConfig.sign_type.equals("MD5") ) {
isSign = MD5.verify(preSignStr, sign, AlipayConfig.key, AlipayConfig.input_charset);
}else if(AlipayConfig.sign_type.equals("RSA")){
isSign = RSA.verify(preSignStr, sign, AlipayConfig.alipay_public_key, AlipayConfig.input_charset);
}
return isSign;
}
示例9: buildRequestMysign
import com.alipay.config.AlipayConfig; //导入依赖的package包/类
/**
* 生成签名结果
* @param sPara 要签名的数组
* @return 签名结果字符串
*/
public static String buildRequestMysign(Map<String, String> sPara) {
String prestr = AlipayCore.createLinkString(sPara); //把数组所有元素,按照“参数=参数值”的模式用“&”字符拼接成字符串
String mysign = "";
if(AlipayConfig.sign_type.equals("MD5") ) {
mysign = MD5.sign(prestr, AlipayConfig.key, AlipayConfig.input_charset);
}
return mysign;
}
示例10: getSignVeryfy
import com.alipay.config.AlipayConfig; //导入依赖的package包/类
/**
* 根据反馈回来的信息,生成签名结果
* @param Params 通知返回来的参数数组
* @param sign 比对的签名结果
* @return 生成的签名结果
*/
private static boolean getSignVeryfy(Map<String, String> Params, String sign) {
//过滤空值、sign与sign_type参数
Map<String, String> sParaNew = AlipayCore.paraFilter(Params);
//获取待签名字符串
String preSignStr = AlipayCore.createLinkString(sParaNew);
//获得签名验证结果
boolean isSign = false;
if(AlipayConfig.sign_type.equals("MD5") ) {
isSign = MD5.verify(preSignStr, sign, AlipayConfig.key, AlipayConfig.input_charset);
}
return isSign;
}
示例11: buildRequestPara
import com.alipay.config.AlipayConfig; //导入依赖的package包/类
/**
* 生成要请求给支付宝的参数数组
* @param sParaTemp 请求前的参数数组
* @return 要请求的参数数组
*/
public static Map<String, String> buildRequestPara(Map<String, String> sParaTemp) {
//除去数组中的空值和签名参数
Map<String, String> sPara = AlipayCore.paraFilter(sParaTemp);
//生成签名结果
String mysign = buildRequestMysign(sPara);
//签名结果与签名方式加入请求提交参数组中
sPara.put("sign", mysign);
sPara.put("sign_type", AlipayConfig.sign_type);
return sPara;
}
示例12: getSignVeryfy
import com.alipay.config.AlipayConfig; //导入依赖的package包/类
/**
* 根据反馈回来的信息,生成签名结果
* @param Params 通知返回来的参数数组
* @param sign 比对的签名结果
* @return 生成的签名结果
*/
private static boolean getSignVeryfy(Map<String, String> Params, String sign) {
//过滤空值、sign与sign_type参数
Map<String, String> sParaNew = AlipayCore.paraFilter(Params);
//获取待签名字符串
String preSignStr = AlipayCore.createLinkString(sParaNew);
//获得签名验证结果
boolean isSign = false;
if(AlipayConfig.sign_type.equals("RSA")){
isSign = RSA.verify(preSignStr, sign, AlipayConfig.ali_public_key, AlipayConfig.input_charset);
}
return isSign;
}
示例13: alipayHandler
import com.alipay.config.AlipayConfig; //导入依赖的package包/类
/**
* 进入支付宝界面
*
* @return
*/
@Action(value = "alipayHandler", results = { @Result(name = "alipayUI", location = ViewLocation.View_ROOT
+ "alipay.jsp") })
public String alipayHandler() throws Exception {
System.out.println("PayAction.alipayHandler()");
//获取需要的参数
int orderId = getIntParameter("id", -1);
if(orderId == -1){
throw new Exception("alipayHandler get parameters error!");
}
Mrcodeorder order = mrcodeorderService.getById(orderId);
//商户订单号,商户网站订单系统中唯一订单号,必填
String out_trade_no = order.getOrderCode();
//订单名称,必填
String subject = "OrderNumber-"+out_trade_no;
//付款金额,必填
String total_fee = order.getDepositPrice().toString();
//商品描述,可空,含有中文会导致校验失败
/*StringBuilder builder = new StringBuilder();
for (OrderDish orderDish : order.getOrderDishes()) {
builder.append("orderId:"+orderDish.getId()+"-DISHNAME-"+orderDish.getDishName()+"-PRICE-"+orderDish.getDishPrice()+"-COUNT-"+orderDish.getDishCount());
}
String body = builder.toString();*/
//String body = "对商品的描述";
String body = order.getOrderCode();
//把请求参数打包成数组
Map<String, String> paramMap = new HashMap<String, String>();
paramMap.put("service", AlipayConfig.service);
paramMap.put("partner", AlipayConfig.partner);
paramMap.put("seller_id", AlipayConfig.seller_id);
paramMap.put("_input_charset", AlipayConfig.input_charset);
paramMap.put("payment_type", AlipayConfig.payment_type);
paramMap.put("notify_url", AlipayConfig.notify_url);
paramMap.put("return_url", AlipayConfig.return_url);
paramMap.put("anti_phishing_key", AlipayConfig.anti_phishing_key);
paramMap.put("exter_invoke_ip", AlipayConfig.exter_invoke_ip);
paramMap.put("out_trade_no", out_trade_no);
paramMap.put("subject", subject);
paramMap.put("total_fee", total_fee);
paramMap.put("body", body);
//建立请求
String sHtmlText = AlipaySubmit.buildRequest(paramMap,"get","确认");
//System.out.println(sHtmlText);
request.setAttribute("sHtmlText", sHtmlText);
return "alipayUI";
}
示例14: verifyResponse
import com.alipay.config.AlipayConfig; //导入依赖的package包/类
/**
* 获取远程服务器ATN结果,验证返回URL
* @param notify_id 通知校验ID
* @return 服务器ATN结果
* 验证结果集:
* invalid命令参数不对 出现这个错误,请检测返回处理中partner和key是否为空
* true 返回正确信息
* false 请检查防火墙或者是服务器阻止端口问题以及验证时间是否超过一分钟
*/
private static String verifyResponse(String notify_id) {
//获取远程服务器ATN结果,验证是否是支付宝服务器发来的请求
String partner = AlipayConfig.partner;
String veryfy_url = HTTPS_VERIFY_URL + "partner=" + partner + "¬ify_id=" + notify_id;
return checkUrl(veryfy_url);
}