购物网站如何接入支付宝后台接口实现支付功能?

购物网站需要接入支付宝或者第三方支付接口,具体如何实现的,可以给一些实例看一下么

已邀请:

//创建支付请求
String result = null;
try {
Map<String, String> sParaTemp = new HashMap<String, String>();
sParaTemp.put("service", "create_direct_pay_by_user");
sParaTemp.put("partner", partner);
sParaTemp.put("seller_email", seller_email);
sParaTemp.put("_input_charset", input_charset);
sParaTemp.put("payment_type", payment_type);
sParaTemp.put("notify_url", notify_url);
sParaTemp.put("return_url", return_url);
sParaTemp.put("out_trade_no", order.getOrderNumber());
sParaTemp.put("subject", "订单号"+order.getOrderNumber());
sParaTemp.put("total_fee", getOrderFee(order));
sParaTemp.put("body", getOrderDetail(order));
sParaTemp.put("anti_phishing_key", AlipayConfig.anti_phishing_key);
sParaTemp.put("exter_invoke_ip", AlipayConfig.exter_invoke_ip);
Map<String, String> sPara = AlipaySubmit.buildRequestPara(sParaTemp);
StringBuffer sb = new StringBuffer();
Set es = sPara.entrySet();
Iterator it = es.iterator();
while(it.hasNext()) {
Map.Entry entry = (Map.Entry)it.next();
String k = (String)entry.getKey();
String v = (String)entry.getValue();
sb.append(k + "=" + URLEncoder.encode(v, input_charset) + "&");
}
String reqPars = sb.substring(0, sb.lastIndexOf("&"));
//将数组拼接成参数
result = AlipaySubmit.ALIPAY_GATEWAY_NEW + reqPars;

return "redirect:" + result;

你可以去支付宝官方网站看到,支付宝提供开发者文档还有demo,很清楚的

citaret

赞同来自:

谢谢

要回复讨论请先登录注册