当前位置: 首页 > news >正文

建设邮箱网站百度商桥怎么绑定网站

建设邮箱网站,百度商桥怎么绑定网站,qq群优惠券里面网站怎么做的,制标易logo设计一、情景描述 当前项目想在微信小程序付款时添加上京东支付支付类型#xff0c;效果如下 普通的付款方式可以直接付款就能完成支付#xff0c;但京东支付无法在小程序上直接付款#xff0c;他需要复制生成的链接#xff0c;然后打开京东app然后在京东平台上付款。 所以效果如下 普通的付款方式可以直接付款就能完成支付但京东支付无法在小程序上直接付款他需要复制生成的链接然后打开京东app然后在京东平台上付款。 所以我们首先需要了解京东支付的支付流程 二、京东支付实现流程 京东支付跟普通支付不同之处就是无法在当前平台完成支付需要复制口令前往京东app在京东app里进行支付操作 具体可查看开放文档 https://mer.jd.com/open/ 文档中也提供了大部分接口demo可以下载参考 简单概括步骤分为3步 1、下单接口 调用这个接口成功的话在响应体中有一个我们需要的数据pay_url支付链接我尝试了一下点击可以进入到京东付款页面但是我们不要直接使用要把这个字段封装成金口令。 注意设置的请求体中有一个字段callbackUrl回调路径设置这个值在支付完成后京东会调用这个路径的接口见3、编写回调方法验证支付订单 下单方法代码参考如下 //京东下单支付生成金口令public static ReturnValueDomainString pay(Tcorderinfo tcorderinfo ) throws Exception {ReturnValueDomainString ret new ReturnValueDomainString();logger.debug(进入京东支付方法进入pay);if (NonUtil.isNon(tcorderinfo)) {return ret.setFail(京东支付订单不可为空);}// 得到openidString openid tcorderinfo.getOpenid();int fee 0;// 得到小程序传过来的价格注意这里的价格必须为整数1代表1分所以传过来的值必须*100if (NonUtil.isNon(tcorderinfo.getAdvancepay())) {fee Integer.parseInt(tcorderinfo.getOrderfee());} else {fee Integer.parseInt(tcorderinfo.getAdvancepay());}double total_amount MathHelper.div(fee, 100, 2);logger.debug(支付费用/元{}, total_amount);// 订单编号String did tcorderinfo.getOrderid();// 订单标题-商品名称String title tcorderinfo.getTradename();MapString, Object requestParam new HashMap();//代理商号 // requestParam.put(agentNum, agentNum);//商户号requestParam.put(customerNum, customerNum);//店铺号 // requestParam.put(shopNum, shopNum);//机具号 // requestParam.put(machineNum, machineNum); // requestParam.put(requestNum, generateId());//订单号requestParam.put(requestNum, tcorderinfo.getOrderid());//订单号requestParam.put(authCode, tcorderinfo.getOpenid());//openidrequestParam.put(bankType, bankType);//支付类型requestParam.put(orderAmount, total_amount);//支付金额requestParam.put(callbackUrl, callbackUrl);requestParam.put(source, source);requestParam.put(orderType, orderType);requestParam.put(payModel, payModel);requestParam.put(payType, payType);requestParam.put(subOrderType, subOrderType);requestParam.put(businessType, businessType);requestParam.put(paySource, paySource);requestParam.put(version, V4.0);requestParam.put(completeUrl, completeUrl);//支付自定义页面MapString, String extraMap new HashMap();extraMap.put(userAgent, UnionPay / 1.0 CEBBANK);requestParam.put(extraInfo, JSON.toJSON(extraMap));String response OpenapiRequestUtil.postOpenapi(api_order,accessKey,secretKey, requestParam);JSONObject res JSONObject.parseObject(response);//添加判断if (!(Boolean) res.get(success)){logger.error(京东下单接口失败{},response);return ret.setFail((String) res.get(msg));}//解析String qrCode JSONObject.parseObject(res.get(bankRequest).toString()).get(PAY_URL).toString();requestParam new HashMap();JSONObject reqData new JSONObject();JSONObject request new JSONObject();request.put(url,qrCodesourceIDxxx);request.put(keyChannel,keyChannel);request.put(sourceCode,sourceCode);request.put(deviceInfo,);reqData.put(request,request);MapString,Object map new HashMap();String url prize_url;//金口令地址map.put(reqData,reqData);System.out.println(金口令请求体map);String str HttpUtil.postFormData(url, map);System.out.println(金口令返回1str);res JSONObject.parseObject(str);//添加判断String code JSONObject.parseObject(res.get(resultData).toString()).get(code).toString();if (code!null 000.equals(code)){} else {String msg JSONObject.parseObject(res.get(resultData).toString()).get(msg).toString();logger.debug(调用金口令接口出现异常{},msg);ret.setFail(京东支付生成金口令出现异常);}//解析String data JSONObject.parseObject(JSONObject.parseObject(res.get(resultData).toString()).get(data).toString()).get(code).toString();logger.debug(获取金口令{},data);return ret.setSuccess(生成金口令响应,str);}httpUtil工具类 import org.slf4j.Logger; import org.slf4j.LoggerFactory;import java.io.*; import java.net.HttpURLConnection; import java.net.URL; import java.util.Map; import java.util.Set;public class HttpUtil {private static Logger logger LoggerFactory.getLogger(HttpUtil.class);public static String postFormData(String url, MapString, Object map) throws Exception {BufferedReader in null;URL urls new URL(url);HttpURLConnection connection null;OutputStream outputStream null;String rs ;try {connection (HttpURLConnection) urls.openConnection();connection.setRequestProperty(Content-Type, multipart/form-data; boundary----footfoodapplicationrequestnetwork);connection.setDoOutput(true);connection.setDoInput(true);connection.setRequestProperty(Accept-Language, zh-CN,zh;q0.8);connection.setRequestProperty(Accept, */*);connection.setRequestProperty(Range, bytes );connection.setConnectTimeout(8000);connection.setReadTimeout(20000);connection.setRequestMethod(POST);StringBuffer buffer new StringBuffer();outputStream connection.getOutputStream();SetMap.EntryString, Object entries map.entrySet();for (Map.EntryString, Object entry : entries) {// 每次都清空buffer避免写入上次的数据buffer.delete(0, buffer.length());buffer.append(------footfoodapplicationrequestnetwork\r\n);Object value entry.getValue();if (!(value instanceof File)) {buffer.append(Content-Disposition: form-data; name\);buffer.append(entry.getKey());buffer.append(\\r\n\r\n);buffer.append(entry.getValue());buffer.append(\r\n);outputStream.write(buffer.toString().getBytes());} else {buffer.append(Content-Disposition: form-data; name\ entry.getKey() \; filename\ ((File) entry.getValue()).getName() \\r\n);buffer.append(Content-Type: zip \r\n\r\n);outputStream.write(buffer.toString().getBytes());File file (File) entry.getValue();DataInputStream ins new DataInputStream(new FileInputStream(file));int bytes 0;byte[] bufferOut new byte[1024];while ((bytes ins.read(bufferOut)) ! -1) {outputStream.write(bufferOut, 0, bytes);}// 文件流后面添加换行否则文件后面的一个参数会丢失outputStream.write(\r\n.getBytes());}}if (entries ! null map.size() 0) {buffer.delete(0, buffer.length());buffer.append(------footfoodapplicationrequestnetwork--\r\n);}outputStream.write(buffer.toString().getBytes());try {connection.connect();if (connection.getResponseCode() 200) {in new BufferedReader(new InputStreamReader(connection.getInputStream(), UTF-8));String line ;while ((line in.readLine()) ! null) {rs line;}}} catch (Exception e) {logger.error(发生异常,e);rs null;}return rs;} finally {try {outputStream.close();if (in ! null){in.close();}} catch (Exception e) {logger.error(发生异常,e);}outputStream null;if (connection ! null)connection.disconnect();connection null;}} } 2、生成金口令 将下单接口返回的pay_url拼接上sourceID京东工作人员会提供作为url字段参数去调用金口令接口 调用成功后可以将生成的金口令响应给前端 3、编写回调方法验证支付订单 在京东平台付款成功后京东平台会调用这个接口我们需要做的2步 1验证签名 通过签名验证订单身份保证订单是自己的订单 验证签名的demo京东线上文档中也提供了可以下载参考 2验证通过后编写付款后的业务逻辑 当然还有退款接口下载账单接口等文档中都提供了可以根据项目情况类比去开发
http://www.zqtcl.cn/news/56210/

相关文章:

  • 织梦网站手机端高端网站改版顾问
  • 精品课网站怎么做windows优化大师卸载
  • 中建建筑网站企业信息系统是什么
  • 昆明森贤网站建设什么是网络营销的核心
  • 好大夫在线网站官网做提眉的医生列举五种常用的网站推广方法
  • 网站充值平台怎么做建一个个人网站要多少钱
  • 微网站建设教程视频教程网站中文商标域名注册
  • 金坛做网站哪家好互联网站源码
  • 谷歌网站怎么打不开wordpress appcan-wp
  • 世纪兴网站建设义乌本地网站开发
  • vue 做企业网站行不怎样在百度上发布信息
  • 代做毕业设计的网站深圳十大广告公司
  • 网站建设的标签指的是高端装饰公司网站设计
  • 网站建设和维护合同书seo资讯
  • 在线教育网站怎样建设邯郸做商城网站的公司
  • 做网站的公司首选智投未来网站建设公司 成本结转
  • 网站设计理念嘉兴seo网络推广
  • 网站开发 强制兼容模式网络营销专业主修课程
  • 营销导向网站建设家装公司取名字大全集
  • 提供网站建设工具网站外接
  • it培训费用大概多少钱四川seo推广
  • 医疗网站建设行情聊城网站建设推广
  • 微网站开发提供的服务器那位学生网站开发
  • 网站的标签修改我所了解的网页制作软件
  • 建筑方案设计作图题广州17年seo优化技术电话
  • 金坛网站建设报价网站怎样备案
  • 专业做外贸的网站贵阳网站开发培训学费
  • 案例seo自然搜索优化排名
  • 网站建设技术 教材网站正在建设中永久
  • 做网站用的大图广州网站建设解决方案